The Wild

Drupal 6 to Drupal 10: Migrate Photos Content Type

· 6 min read · Mammals

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide walks you through migrating a custom "Photos" content type from Drupal 6 to Drupal 10 (or 11) using the core Migrate module and contributed modules. You'll move the content type definition, all photo nodes (including images, titles, bodies, and taxonomy terms), and file references. Before starting, ensure you have a working Drupal 10 site, access to the Drupal 6 database (or a backup), and the ability to install modules via Composer or the admin UI.

What You'll Need

  • A Drupal 10 or 11 site installed and running (clean or with other content).
  • Access to the Drupal 6 database credentials (or a SQL dump file).
  • Composer installed on your server or local environment (to add migration modules).
  • Admin access to the Drupal 10 site (to install modules and run migrations).
  • Basic familiarity with Drush or the Drupal admin interface.

Step-by-Step

  1. Back up both sites. Export the Drupal 6 database (e.g., via phpMyAdmin or mysqldump) and back up your Drupal 10 site files and database. This is non-negotiable.
  2. Install required modules on Drupal 10. Using Composer, run: composer require drupal/migrate_plus drupal/migrate_tools drupal/migrate_upgrade. Then enable them via Drush or admin UI.
  3. Prepare the Drupal 6 source. If your Drupal 6 site is still online, ensure it's accessible. If not, restore the database to a local environment or use a SQL dump. You'll need the database host, name, user, and password.
  4. Create a migration group. In Drupal 10, go to Admin > Structure > Migrate groups, add a new group (e.g., "d6_photos"). This groups your migration definitions.
  5. Define the source and destination. In the migration group, add a source for the Drupal 6 database (using the migrate_plus module's source plugin). Set the destination to Drupal 10's default content entity.
  6. Write migration YAML files. Create a custom module (or use a contributed module) to hold your migrations. Define at least three migrations: one for the content type, one for the photo nodes, and one for file entities (images). Example structure: migrations/d6_photo_type.yml, d6_photo_node.yml, d6_photo_file.yml.
  7. Migrate the content type. In d6_photo_type.yml, map the Drupal 6 node type (e.g., 'photo') to a new Drupal 10 content type (e.g., 'photo'). Include fields like title, body, and any custom fields (e.g., image, date). Use the migrate_plus plugin for entity type configuration.
  8. Migrate the files (images). In d6_photo_file.yml, use the d6_file source plugin to read the Drupal 6 file table. Map the file path and filename to Drupal 10's managed file system. Use a file destination plugin to create file entities.
  9. Migrate the photo nodes. In d6_photo_node.yml, use the d6_node source plugin. Map the node ID, title, body, and the image field (using the migrated file ID). Also map taxonomy term references if your Drupal 6 photos had categories.
  10. Run the migrations. Use Drush: drush migrate:import d6_photo_type, then drush migrate:import d6_photo_file, then drush migrate:import d6_photo_node. Run them in that order to ensure dependencies are met.
  11. Verify the migration. Check the content type appears in Drupal 10, view a few photo nodes to confirm images display, and test editing a node to ensure fields work.
  12. Clean up. After verification, remove the migration modules (or keep them for future migrations) and delete the migration group if no longer needed.

Common Mistakes

  • Running node migration before files. If you migrate nodes first, the image field will reference file IDs that don't exist yet, causing broken images. Always migrate files first.
  • Ignoring file paths. Drupal 6 stored files in sites/default/files. Ensure the Drupal 10 file system path matches or use a path mapping in the migration.
  • Not mapping taxonomy vocabularies. If your photos used categories, you must migrate the vocabulary and terms first, then map the term IDs.
  • Forgetting field type differences. Drupal 6 text fields may have different formats (e.g., filtered HTML). Migrate the text format or map to a safe format like 'basic_html'.
  • Overlooking revisions. If you need revision history, you must add a separate migration for node revisions. Most basic migrations skip this.

Tips

  • Use the migrate:upgrade command from migrate_upgrade module to auto-generate a full migration set. It will create all necessary YAML files, which you can then tweak for your Photos type.
  • Test on a staging site first. Migrate a small subset (e.g., 10 nodes) using the --limit option in Drush to catch issues early.
  • Keep the Drupal 6 site's file directory accessible during migration. You can copy the files to a temporary location on the Drupal 10 server.
  • Use the Migrate Tools UI (admin/structure/migrate) to monitor migration status and roll back if needed.
  • If you have many images, consider using the file_public destination plugin to copy files into the public file system automatically.

Troubleshooting

  • Migration fails with "File not found" errors. Check the source file path in the Drupal 6 database. Sometimes the path is relative to the Drupal root. Adjust the source file path in your YAML to the full absolute path or copy the files to the expected location.
  • Images appear broken after migration. Verify the file migration created file entities and that the node's image field references the correct file ID. Use the migrate status to see if any file rows were skipped.
  • Content type doesn't appear. Ensure the content type migration ran successfully. Check the migrate status output for errors. The content type may have been created but not displayed if the display settings aren't configured. Go to Structure > Content types and check.
  • Taxonomy terms not attached. If you didn't migrate terms first, the node migration will fail. Run the term migration first, then re-run the node migration.
  • Rollback and retry. If a migration partially fails, use drush migrate:rollback to undo it, fix the issue, and re-import.

Frequently Asked Questions

Can I migrate directly from Drupal 6 to Drupal 10 without intermediate steps?

Yes, the Migrate module supports direct migration from Drupal 6 to Drupal 10. You don't need to go through Drupal 7 or 8.

Do I need to migrate the file system separately?

Yes, files are stored in the database (file_managed table) and physically on disk. You must migrate the file entities and copy the actual files to the Drupal 10 file directory.

What if my Drupal 6 site has custom fields on the Photos content type?

You'll need to define those fields in Drupal 10 first (e.g., create the field via admin UI or code), then map them in the migration YAML using the field names.

Can I use the migrate_upgrade module to auto-generate migrations?

Yes, the migrate_upgrade module can generate a full migration set from a Drupal 6 database. It's a great starting point, but you'll likely need to edit the YAML for your specific Photos type.

How long does the migration take?

It depends on the number of nodes and images. A few hundred nodes typically take minutes. Large sites with thousands of images may take longer; use batch processing via Drush if needed.

Will my Drupal 6 URLs (aliases) be preserved?

By default, no. You need to migrate the URL alias table separately using the d6_url_alias source plugin. Include that in your migration set if you want to keep old links working.