Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've been testing out the is_new flag for user migrations from D6 to D7 using the migrate_ui mapping system. Based on https://drupal.org/node/1349632#is_new, I expected the sourceid = destinationid when is_new = TRUE. However, after import, the sourceid <> destinationid. This is because, when is_new = TRUE, uid must be mapped to the relevant source field in order for it to take effect.
$this->addFieldMapping('uid', 'uid')
->description(t('Preserve old user ID as uid in Drupal'));
$this->addFieldMapping('is_new')
->defaultValue(TRUE);
However, it is not currently possible to map uid/nid using migrate_ui as they are destination key columns.
Comment | File | Size | Author |
---|---|---|---|
#16 | migrate.migrate-ui.2105037-16.patch | 753 bytes | mrP |
Comments
Comment #1
mrP CreditAttribution: mrP commentedIt would appear uid and nid should be available as destination fields when editing mappings (for example, at admin/content/migrate/groups/beer/BeerUser/edit) if is_new <> DNM.
When commenting out is_new in migrate_example/beer.inc
and manually adding mappings in migrate_example/beer.inc
Once doing so, the user id mappings are correct at admin/content/migrate/groups/beer/BeerUser and the default value for is_new = 1.
Comment #2
mrP CreditAttribution: mrP commentedsame issue with latest dev
Comment #3
mrP CreditAttribution: mrP commentedI believe major is the appropriate priority level
Comment #4
mrP CreditAttribution: mrP commentedThe patch adds a check to allow mapping the $dest_key when is_new = TRUE. Not the most elegant patch in the world, but it seems gets the job done.
Comment #4.0
mrP CreditAttribution: mrP commentedUpdated issue summary.
Comment #5
mrP CreditAttribution: mrP commentedadded a check for migrations that don't support the is_new mapping
Comment #6
mrP CreditAttribution: mrP commentedfixing a typo. third time's a charm they say...
Comment #7
mrP CreditAttribution: mrP commentedComment #8
mikeryanCoding standards: space after if.
$default_is_new is tested, but may not have been set. Simplest would be to default it to 0 above.
Comment #9
mrP CreditAttribution: mrP commentedThanks reviewing the patch mike.
Attached is a re-roll with your suggested changes. Feel free to tweak further as you see fit.
Comment #10
Steve Hanson CreditAttribution: Steve Hanson commentedI profess to still be a little confused by this. As far as I can tell, even with this patch applied it is still impossible to map NID to NID ? Or am I missing something?
I have set is_new to default to TRUE - but still do not get a way to map NID as a destination in the UI.
OOOOHHHH -- never mind, I see -- literally is_new has to be 1 -- not TRUE.
Comment #11
mrP CreditAttribution: mrP commentedadd a note that TRUE = 1 in migrate_ui
Comment #12
aitala CreditAttribution: aitala commentedI'm finding this very confusing at a UI level - what is supposed to be set to get the destination UIDs equal to the source UIDs?
Also, what happens on rollback to the sequences table? I've done this several times and it keep incrementing. I would assume on rollback it would be reset...
Eric
Comment #13
MixologicGlad I found this issue. The UI is wildly unclear.
Comment #14
Mixologicis_new should be in quotes. Otherwise its interpreted as a constant.
Comment #15
13rac1 CreditAttribution: 13rac1 commentedBased on above comments, this needs work.
Comment #16
mrP CreditAttribution: mrP commentedThanks all for comments. I'm glad to see this issue maintaining some momentum.
Re-rolled patch with suggestions attached.
Comment #17
mrP CreditAttribution: mrP commentedComment #19
mikeryan