phpdrupaldrupal-8drupal-modulesdrush

Drupal 7 to 9 migration - how to customize the migration yml generated by migrate-upgrade


Am trying to customize migrations so that i can map the data to specific fields but after i edit files am not able to place then to active configuration successfully.

My process so far

how i generated the files

Step 1. Generation of migration files

drush migrate:upgrade --legacy-db-key=migrate --legacy-root=http://localhost/drupal7 --configure-only

Step 2. Creation of a custom module

modules/custom/my_custom_migrations

inside i have config/install folder

Step 3. Exporting the migrations created to my module

drush cex --destination=/Users/mac/Sites/drupal9/web/modules/custom/my_custom_migrations/config/install

Step 4. I modified the yml files then tried the following import stript

drush cim —source=/Users/mac/Sites/drupal9/web/modules/custom/my_custom_migrations/config/install

this deleted all my migrations on the active configuration and never updated with my customized ones

Step 5. I then added the my_custom_migrations.info.yml in the custom module and run

drush en my_custom_migrations -y

this created my migrations in the active configuration but i got and error when trying drush ms

part of error

[error]  TypeError: Argument 1 passed to Drupal\migrate\Plugin\Migration::getProcessNormalized() must be of the type array, null given, called in /Users/mac/Sites/drupal9/web/core/modules/migrate/src/Plugin/Migration.php on line 706 in Drupal\migrate\Plugin\Migration->getProcessNormalized() (line 451 of /Users/mac/Sites/drupal9/web/core/modules/migrate/src/Plugin/Migration.php) #0 /Users/mac/Sites/drupal9/web/core/modules/migrate/src/Plugin/Migration.php(706): Drupal\migrate\Plugin\Migration->getProcessNormalized(NULL)

How can i either fix the error or make the drush cim to work as it should


Solution

  • I have figured how to update the migrations in the active configuration

    Step 1. Config export everything to a folder in my case i added a tmp folder in config in my custom module

    drush cex --destination=/Users/mac/Sites/drupal9/web/modules/custom/my_custom_migrations/config/install 
    

    Step 2. Edit the yml files that you want then run the Config import status which will only import the migrations that have changes to your active configuration

    drush cim status --source=/Users/mac/Sites/drupal9/web/modules/custom/my_custom_migrations/config/tmp