Term migration is no-doubt a cool feature that helps to automatically migrate nodes that has term reference fields.
A site usually has more than just contents, and views and panels are the most common building blocks. They may rely on taxonomy, and use certain term IDs as settings. Occasional rollback of term migration(s) will invalidate all the views and panels
that use previously migrated terms. A fool-protection is strongly required here.

Comments

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

Is this meant for migrate_d2d, or do you consider it a general Migrate issue?

Can you explain a bit more about the situation? How would you visualize Migrate protecting you if you build things like views and panels on migrated data then rollback that data?

lex0r’s picture

StatusFileSize
new1.66 KB

My explanation is inside the patch ;)
It allows to protect a term migration from occasional rollback that will break the site.

lex0r’s picture

Status: Postponed (maintainer needs more info) » Active

Can you explain a bit more about the situation? How would you visualize Migrate protecting you if you build things like views and panels on migrated data then rollback that data?

Okay, a use case:
Bob who did migration didn't warn John not to rollback term migration, though some of the views used certain term IDs as filter values, and some of the panels used term IDs as context.
John decides to re-migrate everything, and he ends up with views/panels not working since they rely on non-existent terms.
My idea is an option to term migration that prevents it from rollback (we don't really need to remigrate taxonomy so many times, especially when there's something already built on top of it!).

mikeryan’s picture

Title: Rollback of term migration breaks views/panels settings » Protect particular migrations, or specific rows, from rollback
Project: Drupal-to-Drupal data migration » Migrate
Version: » 7.x-2.x-dev
Assigned: Unassigned » mikeryan

This is rather narrow - only terms, and only for migrate_d2d. In the meantime, I'm seeing other scenarios where I'd like to protect particular rows from rollback - see the role_mappings support in migrate_d2d, where we want to be sure we don't delete any pre-existing roles we've mapped to. This calls for a more general solution in Migrate itself.

I think what we need is a new map table column for rollback behavior - default value of 0 for normal rollback, 1 to not delete the destination item. Maybe we could also use this with file migrations for the preserve_files option - a 2 would mean delete the DB tracking of the item, but not the underlying resource (file).

q11q11’s picture

Any use of resetting auto-increment column in particular tables (in delicate situations) ?
As example - source taxonomy data changed, but we already protect destination from re-migration and we must preserve TIDs.

mikeryan’s picture

I would not mess around with the auto-increments - I take it you're imagining if you reset it and remigrate you'll get exactly the same tids, but that's not going to be reliable - the order of migration might not be deterministic, if source data has been deleted or added in the middle it will throw the count off, if someone manually creates terms, etc.

The goal of this issue is to let you simply preserve the tids, there shouldn't be any need to hack the increments.

mikeryan’s picture

Status: Active » Needs review
StatusFileSize
new10.42 KB

OK, here's a patch - @lex0r, can you try this? To prevent rolling back of all content in a given migration, add to your migration constructor:

$this->defaultRollbackAction = MigrateMap::ROLLBACK_PRESERVE;

To prevent particular rows from being rolled back, add this to prepareRow():

$this->rollbackAction = MigrateMap::ROLLBACK_PRESERVE;
mikeryan’s picture

Status: Needs review » Fixed

Committed for D6 and D7.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.