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.
Hello,
I have several file and image fields attached to users on the source D7 website that I'm trying to migrate.
I extended DrupalUser7Migration and added those field mappings:
// File fields.
$this->addFieldMapping('field_user_profile_picture', 'field_profile_picture')
->sourceMigration('CrosMigrateImportFiles');
$this->addFieldMapping('field_user_profile_picture:file_class')
->defaultValue('MigrateFileFid');
$this->addFieldMapping('field_user_profile_picture:width', 'field_profile_picture:width');
$this->addFieldMapping('field_user_profile_picture:height', 'field_profile_picture:height');
$this->addFieldMapping('field_user_cv', 'field_cv')
->sourceMigration('CrosMigrateImportFiles');
$this->addFieldMapping('field_user_cv:file_class')
->defaultValue('MigrateFileFid');
$this->addFieldMapping('field_user_cv:display', 'field_cv:display');
All files are imported correctly in the file_managed table by my DrupalFile7Migration (called CrosMigrateImportFiles) but the tables related to those 2 field mappings above are not populated.
I guess I should do something similar to the picture migration which I tried but with no luck.
Any idea how to achieve this?
Thank you very much,
Hervé
Comments
Comment #2
herved CreditAttribution: herved at Randstad Digital commentedOk I managed to do this by importing those files first (using a dedicated migration below).
Then I had to reference it on the field mappings in my user migration - using ->sourceMigration(MyMigrateImportUserFiles).
And finally update the uid in the file_managed table in the complete method of my user migration.
Switching this to fixed.