I've finally migrated from my Drupal 6 website to this new Drupal 8 one. I did this using the Migrate Source CSV module which turned out much simpler than using Migrate Upgrade or creating a custom migration.
Why use CSV export?
I had initially tried using Migrate Upgrade, but it was migrating too much junk, and I wanted just to migrate the content of the 'Today' content type. Also I had cleaned up the content type quite a bit, so the fields are different as well.
Step 1: Get the export
Create an export.sql
file with the appropriate selects of the content you want to import. In this example, it is nodes from my custom content type, 'today'.
select nd.nid as old_nid, title, created, field_today_value from node nd JOIN content_type_today td ON nd.nid = td.nid WHERE status = 1 ORDER BY created ASC;
Run the export and pipe to a export_pipe.csv
file, with |
as delimiter.
mysql -u mysqluser -p mydrupalsitedb < export.sql | sed 's/\t/|/g' > export_pipe.csv
Step 2: Prepare for migration:
Download following modules:
- Migrate Source CSV
- Migrate (required by migrate_plus)
- Migrate Tools (required by migrate_plus)
- Migrate Plus (required by migrate_plus)
Enable the modules:
drush en migrate_source_csv, migrate, migrate_tools, migrate_plus -y
Step 3: Set up the migration
This is based on the instructions on Migrate Source CSV's documentation.
Go to `admin/config/development/configuration/single/import`
, select 'Migration'. Enter this into the textbox:
In addition to the instructions on Migrate Source CSV's documentation, I have amended my yml to include:
- use
|
as delimiter instead of the default,
- import my field
field_today_value
into the body part (not summary) of my new 'body and summary' text field in drupal 8 - import my field
field_today_value
into the body field as Full HTML format. - set the last updated date of the imported node as the node created date of my original node (the line `changed: created`)
- hardcode the creator id of the imported nodes as uid 2
Step 4: Run the migration
On the server, run:
drush migrate-import mymigration
Or if dissatisfied with the results, roll-back:
drush migrate-rollback mymigration
To tweak the YML, edit the migrate_plus.migration.mymigration.yml
file in your configuration sync export and then re-import it.
Step 5: Clean up
You can now uninstall the migrate modules:
drush pmu migrate_source_csv, migrate, migrate_tools, migrate_plus