The migrate_example BeerUser migration sets up deduping of usernames. Running

drush mi beerterm
drush mi beeruser

Gives usernames alice, alice_2, bob, and charlie. Then running

drush mi --update beeruser

changes the username to alice, alice_3, bob_2, charlie_2. So, we need to be sure not to rewrite usernames when updating existing content.

Comments

mikeryan’s picture

Title: dedupe() overdupes on --update » dedupe() overdedupes on --update

This is harder than it looks. If we simply skip the dedupe logic when updating existing content, we get "Integrity constraint violation: 1062 Duplicate entry 'alice' for key 'name'" on the 2nd alice account - we've passed through the original "alice", which conflicts with the first "alice". We want to keep "alice_2" on that account - but the logic is applied before we have the destination side in hand - all we know is we have a source username of "alice" and don't know which is the right deduped username corresponding to the current source row.

It seems like we may need to procrastinate handling of dedupe() to the prepare() stage...

donquixote’s picture

It seems like we may need to procrastinate handling of dedupe() to the prepare() stage...

Yes, that sounds absolutely reasonable.
Is this difficult to pull off?

EDIT:
I might help out, if in return you accept my patches in other issues :)

mikeryan’s picture

Status: Active » Fixed

Finally, fixed on D6 and D7! I was able to do it in the current handleDedupe() function. It should be noted that, because we don't know at update time what the original intended value was, using dedupe() means that the field being deduped will not be updated from the source value. I.e., if you migrate a user whose source username was frank, and they get deduped to frank_1, if they get changed to bill on the source side an update will still maintain frank_1.

Status: Fixed » Closed (fixed)

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