Migration Generate Step-by-Step¶
We are going to work on a clean D8 site. So, issue something similar to:
1 | drush dl drupal --drupal-project-rename=docroot && cd docroot && drush si -y standard |
Enable Migrate required modules¶
We are going to use:
- Migrate Upgrade
- Migrate Plus
- Migrate Tools
In the Drupal root, run:
drush en -y migrate_upgrade
Edit settings.php to define a DB connection¶
After $databases['defaul']['default'] = [] array define the connections for migrate tasks:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | $databases['upgrade']['default'] = array ( 'database' => 'avcodb', 'username' => 'lovelyUserName', 'password' => 'impossiblePasswd', 'prefix' => '', 'host' => 'localhost', 'port' => '3306', 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', 'driver' => 'mysql', ); // Pay special attention to the keys! (ie: 'acvod6') // This key needs to match the key defined in your migrate_plus.migration_group.migrate_drupal_6.yml file. $databases['acvod6']['default'] = array ( 'database' => 'avcodb', 'username' => 'lovelyUserName', 'password' => 'impossiblePasswd', 'prefix' => '', 'host' => 'localhost', 'port' => '3306', 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', 'driver' => 'mysql', ); |
Create a custom module to tweak migrations¶
Drupal Console is really useful for this
1 | drupal gm |
Remember to add migrate_upgrade as a dependency!
Generate a migration¶
Once D8 fresh site is installed, you defined the DB connection in settings.php, and migrate dependencies are in place, we can generate our migration.
drush migrate-upgrade --legacy-db-url='mysql://lovelyUserName:impossiblePasswd@localhost/avcodb' --legacy-root=/home/eu/git-mbm/acvo/docroot --configure-only
When this is done, we are going to add those migrate configs to our custom module, in order to tweak them as needed.
- Export migration to a tmp dir
drush config-export --destination=/tmp/migrate_configs
-
Copy yaml migration configs into “orig” directory, so we can keep them unaltered in there in case we need them later.
3. Finally copy yaml config files into our Custom Migration Module “config/install” directory. So we can remove the ones that we do not want, tweak them, etc…1
cp /tmp/migrate_configs/migrate_plus.migration.* /tmp/migrate_configs/migrate_plus.migration_group.migrate_*.yml modules/custom/acvo_custom_migration/orig
1 | rsync -avz modules/custom/acvo_custom_migration/orig/ modules/custom/acvo_custom_migration/config/install |
So now, we will remove yaml file for those things we do not want to migrate, for example:
- Node Revisions
- Comments
- System configs
Install fresh D8 (yes, once again)¶
1 | drush si -y standard |
Enable Required modules¶
You should enable all the D8 ported modules that you were using on your migrated site. For the modules that have no ports to D8, we are going to need some manual tweaking to be able to map the D6 module to the new D8 one.
Here is the table with modules that we need to enable in D8 (both Core, Contrib and my custom migration module)
Modules Table
| Package | Name | Type | Version |
|---|---|---|---|
| Access control | Content Access (content_access) | Module | 8.x-1.0-alpha1 |
| Access control | Menu Per Role (menu_per_role) | Module | 8.x-1.0-alpha1 |
| Administration | Admin Toolbar (admin_toolbar) | Module | 8.x-1.21 |
| Administration | Admin Toolbar Extra Tools (admin_toolbar_tools) | Module | 8.x-1.21 |
| Administration | Adminimal Admin Toolbar (adminimal_admin_toolbar) | Module | 8.x-1.5 |
| Chaos tool suite | Chaos tools (ctools) | Module | 8.x-3.0 |
| Core | Automated Cron (automated_cron) | Module | 8.4.2 |
| Core | Block (block) | Module | 8.4.2 |
| Core | Breakpoint (breakpoint) | Module | 8.4.2 |
| Core | CKEditor (ckeditor) | Module | 8.4.2 |
| Core | Color (color) | Module | 8.4.2 |
| Core | Comment (comment) | Module | 8.4.2 |
| Core | Configuration Manager (config) | Module | 8.4.2 |
| Core | Contact (contact) | Module | 8.4.2 |
| Core | Contextual Links (contextual) | Module | 8.4.2 |
| Core | Custom Block (block_content) | Module | 8.4.2 |
| Core | Custom Menu Links (menu_link_content) | Module | 8.4.2 |
| Core | Database Logging (dblog) | Module | 8.4.2 |
| Core | Field (field) | Module | 8.4.2 |
| Core | Field UI (field_ui) | Module | 8.4.2 |
| Core | Filter (filter) | Module | 8.4.2 |
| Core | Help (help) | Module | 8.4.2 |
| Core | History (history) | Module | 8.4.2 |
| Core | Internal Dynamic Page Cache (dynamic_page_cache) | Module | 8.4.2 |
| Core | Internal Page Cache (page_cache) | Module | 8.4.2 |
| Core | Menu UI (menu_ui) | Module | 8.4.2 |
| Core | Node (node) | Module | 8.4.2 |
| Core | Path (path) | Module | 8.4.2 |
| Core | Quick Edit (quickedit) | Module | 8.4.2 |
| Core | RDF (rdf) | Module | 8.4.2 |
| Core | Search (search) | Module | 8.4.2 |
| Core | Shortcut (shortcut) | Module | 8.4.2 |
| Core | System (system) | Module | 8.4.2 |
| Core | Taxonomy (taxonomy) | Module | 8.4.2 |
| Core | Text Editor (editor) | Module | 8.4.2 |
| Core | Toolbar (toolbar) | Module | 8.4.2 |
| Core | Tour (tour) | Module | 8.4.2 |
| Core | Update Manager (update) | Module | 8.4.2 |
| Core | User (user) | Module | 8.4.2 |
| Core | Views (views) | Module | 8.4.2 |
| Core | Views UI (views_ui) | Module | 8.4.2 |
| Core (Experimental) | Migrate (migrate) | Module | 8.4.2 |
| Core (Experimental) | Migrate Drupal (migrate_drupal) | Module | 8.4.2 |
| Core (Experimental) | Migrate Drupal UI (migrate_drupal_ui) | Module | 8.4.2 |
| Custom | acvo_custom_migration (acvo_custom_migration) | Module | |
| Development | Devel (devel) | Module | 8.x-1.2 |
| Domain | Domain (domain) | Module | 8.4.2 |
| Domain | Domain Access (domain_access) | Module | 8.4.2 |
| Domain | Domain Configuration (domain_config) | Module | 8.4.2 |
| Domain | Domain Content (domain_content) | Module | 8.4.2 |
| Entity Print | Entity Print (entity_print) | Module | 8.x-1.3 |
| field | Field Permissions (field_permissions) | Module | 8.x-1.0-beta4 |
| Field types | Address (address) | Module | 8.x-1.3 |
| Field types | Datetime (datetime) | Module | 8.4.2 |
| Field types | File (file) | Module | 8.4.2 |
| Field types | Image (image) | Module | 8.4.2 |
| Field types | Link (link) | Module | 8.4.2 |
| Field types | Multiselect (multiselect) | Module | 8.x-1.0 |
| Field types | Options (options) | Module | 8.4.2 |
| Field types | Text (text) | Module | 8.4.2 |
| Fields | Conditional Fields (conditional_fields) | Module | 8.x-1.0-alpha4 |
| Fields | Field Group (field_group) | Module | 8.x-3.0-beta1 |
| Fields | Select (or other) (select_or_other) | Module | 8.x-1.0-alpha3 |
| File metadata | File metadata - EXIF (file_mdm_exif) | Module | 8.x-1.1 |
| File metadata | File metadata manager (file_mdm) | Module | 8.x-1.1 |
| Media | ImageMagick (imagemagick) | Module | 8.x-2.2 |
| Migration | Drupal Upgrade (migrate_upgrade) | Module | 8.x-2.0-beta1 |
| Migration | Migrate Plus (migrate_plus) | Module | 8.x-4.0-beta2 |
| Migration | Migrate Tools (migrate_tools) | Module | 8.x-4.0-beta2 |
| Other | Backup and Migrate (backup_migrate) | Module | 8.x-4.0-beta3 |
| Other | Pathauto (pathauto) | Module | 8.x-1.0 |
| Other | Token (token) | Module | 8.x-1.0 |
| Performance and scalability | Fast 404 (fast404) | Module | |
| Statistics | Google Analytics Lite (google_analytics_lite) | Module | 8.x-1.1 |
| Views | Better Exposed Filters (better_exposed_filters) | Module | 8.x-3.0-alpha3 |
| Views | Views Bulk Operations (views_bulk_operations) | Module | 8.x-1.0 |
| Views | Views Data Export (views_data_export) | Module | 8.x-1.0-alpha4 |
| Views Bulk Operations | Views Bulk Edit (views_bulk_edit) | Module | 8.x-2.0-beta1 |
| Web services | RESTful Web Services (rest) | Module | 8.4.2 |
| Web services | Serialization (serialization) | Module | 8.4.2 |
| Web services | Serialization (CSV) (csv_serialization) | Module | 8.x-1.0 |
| Core | Bartik (bartik) | Theme | 8.4.2 |
| Core | Seven (seven) | Theme | 8.4.2 |
| Other | Adminimal (adminimal_theme) | Theme | 8.x-1.3 |
In order to install and enable these, I have created two scripts in order to add composer dependencies and enabling drupal modules.
Backup D8 fresh install with required modules enabled¶
Just run a DB backup, so you can restore after generating the migration.
drush mysql-dump > ../db_bups/acvod8.local.clean_2017_12_21.sql
Check Migrate configs¶
Enable the custom migration module first!
drush en acvo_custom_migration -y
To make sure we are running our defined migrations config files (and any other tweak we did on our custom module) we run:
drush migrate-status
And we check if the selected yml files are in there as migrations.
At this point you could make a few different decisions
- Manually create the CTs, add fields, etc in your fresh D8 site. And then, you will be able to use the custom module yml files, add Source, Process and Destination plugins, in order to map your fields and CTs before the migration.
- Run each migration, cross your fingers
, and hope the migrations will just work out-of-the-box - Run all the migrations!!



So… things will probably break. We have to accept that fact, and start tweaking, fixing and debugging each migration.
A good approach is to start importing each content type migration, using the –execute-dependencies
drush migrate-import --execute-dependencies upgrade_d6_node_member_information
UPDATE 02/01/2018¶
- Import Profile Pictures (D6 core profile module) and create file entities with it.
- Being able to attach those file entities to user entities. Up to now, the Files have the UID, but the table user__field_profile_image is not populating the image fields… probably a missing some join?