Editorial illustration; the stages describe an import workflow and are not a live Drupal administration screen.
A content migration almost never fails because Drupal cannot read a CSV or JSON feed. It fails because a body field contains legacy inline HTML that breaks your theme, an author reference silently drops, a path alias collides with an existing landing page, or a second import run duplicates 400 articles.
Drupal’s Migrate API gives you a solid extract-transform-load pipeline, especially when paired with migrate_plus and migrate_tools. The habit that separates a smooth launch from a weekend recovery effort is rehearsing the import on a small fixture until you can predict exactly what every row becomes—and how to undo it cleanly.
Lock the Destination Model Before Writing Mappings
Start by listing the target content types, media bundles, taxonomy vocabularies, users, and URL alias patterns in Drupal. If the destination content model is still shifting mid-sprint, pause the migration YAML work. Writing process plugins against moving field machine names creates churn and hidden bugs.
For each source column, write down an explicit mapping decision rather than a vague note:
| Source field | Destination | Transformation rule |
|---|---|---|
id |
Migrate source ID | Required primary key; never use title |
title |
node.title |
Trim whitespace; truncate or fail if >255 chars |
body_html |
field_body |
Strip deprecated <font> tags; map to basic_html |
category |
field_category |
entity_lookup or entity_generate on tags |
old_url |
path/alias |
Check collisions against existing aliases |
Pick an Immutable Source Identifier
Every migration needs a ids: key in its source plugin configuration. Always use an immutable primary key from the legacy database or export—never an article title or slug that an editor might tweak between export passes.
Drupal stores the mapping between source IDs and destination entity IDs in migrate_map_<migration_id> tables. Keeping that legacy ID intact gives you an audit trail when a stakeholder asks three weeks later which legacy record produced a specific node.
Order Dependencies and Handle Missing References Explicitly
Content rarely lives in isolation. An article depends on an author user, taxonomy terms, and media entities. Run your migrations in dependency order:
- Users or author profiles
- Taxonomy terms
- Files and Media entities
- Referenced landing pages or parent nodes
- Articles and dependent content
Decide upfront what happens when a referenced term or author is missing from the source export. Using skip_on_empty or default_value in your process: pipeline makes the behaviour explicit. Silent fallbacks—like assigning every orphan article to uid: 1 without logging it—are painful to untangle after launch.
Rehearse With a Dirty 10-Row Fixture
Do not test your migration by importing all 5,000 rows on the first try. Build a small CSV or JSON fixture of 8 to 12 rows specifically chosen to break your assumptions:
- One clean, ordinary article
- One row with empty optional fields (missing summary or image)
- One row with malformed HTML, tables, or embedded iframes
- One unpublished or archived item
- One row with non-ASCII characters, quotes, or an awkward legacy URL
Run just that fixture in a disposable local environment (such as DDEV) and inspect the resulting nodes as both an admin and an anonymous visitor. Checking database row counts is not enough; you need to open the rendered pages and verify headings, inline images, and links.
Verify Reruns and Rollbacks Before Scaling Up
Real migrations almost always require a correction pass when editors spot a formatting issue or provide an updated export. Test idempotency early using migrate_tools Drush commands:
# Check migration status and counts
drush migrate:status
# Import a specific subset of IDs for quick verification
drush migrate:import legacy_articles --idlist=101,102,105
# Rerun updated rows without duplicating entities
drush migrate:import legacy_articles --update --idlist=101
# Inspect any warnings or skipped-row messages
drush migrate:messages legacy_articles
# Test rollback cleanly on staging
drush migrate:rollback legacy_articles
Run the fixture once, tweak one value in the source file, run with --update (or track_changes: true), and confirm the existing node updates in place instead of spawning a duplicate.
Record a Recovery Plan That Respects Post-Import Edits
Keep your migration definitions in configuration management (drush cex) alongside the codebase—see Drupal Configuration Changes Should Travel as Code for the broader workflow.
Before touching production, take a verified database snapshot:
drush sql:dump --gzip > pre-migration-backup.sql.gz
Document who is running the import, the exact commands, expected row counts, and what rollback means. If editors have not touched the site yet, drush migrate:rollback or restoring the pre-import SQL dump is straightforward. Once editors start publishing manual changes alongside migrated content, a blanket rollback can wipe legitimate work—so knowing how to isolate and re-run specific --idlist batches becomes essential.
Run the production import during a quiet window, capture the CLI output and migrate:messages, and verify counts by bundle and publication status before declaring the migration done.