1

I'm writing some migrations using the Migrate module. I need to set up redirects after I migrate in an item, but I'm not sure where to perform that action.

I can do it in the complete() function for the migration, which is called after each object has successfully been inserted. At that point, I'd have enough information to programmatically add a redirect.

However, if I needed to roll back the migration, I don't see where I can put in any clean up code to remove those redirects. There are pre and post rollback functions, but those are called before the entire migration is rolled back.

I suppose one alternative would be to, in a pre rollback, query the map table for all the objects and then lookup and destroy the redirects like that. Seems ugly.

I think the best solution here is to have a pre/post rollback function available on a per-object basis.

Anyone run into this previously or have suggestions?

1

The redirects associated with the migrated (node) content should be automatically removed during the rollback.

  • Ah I was making an assumption that the redirects were not directly related to node ID's. Looks like they are! I think the question still stands on its own a bit, because there could be cases where this type of relationship doesn't exist on data you're migrating in. – Brian Oct 16 '13 at 18:22
  • This is really a comment, and not an answer. But, since it is accepted, it should be edited to make it more answer-like. – mpdonadio Oct 16 '13 at 21:07
  • Yeah, I couldn't add a comment earlier today (not enough points). I will edit now to convert to an answer. – Dave Bruns Oct 16 '13 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.