DrupalOrg Migrate
Migrations for Drupal 7 (www.drupal.org) to Drupal 10.
Content types, files, users... configuration is already on the site's
config
folder.
Initial setup.
Create a database backup of your personal drupal.org copy and bring that copy locally:
# SSH to remote.
ssh <your-user>@devwww.drupalsystems.org
cd /var/www/dev/<your-user>-drupal.dev.devdrupal.org/htdocs/
drush sql-dump --result-file --gzip
# Back to your local (ctrl + d).
mkdir -p backups
scp <your-user>@devwww.drupalsystems.org:/home/<your-user>/drush-backups/<full-path-to-file>.sql.gz backups/drupal7.sql.gz
gunzip backups/drupal7.sql.gz
ddev import-db --target-db=migrate <backups/drupal7.sql
gzip backups/drupal7.sql
# SSH to remote, clean-up.
ssh <your-user>@devwww.drupalsystems.org
rm /home/<your-user>/drush-backups/<full-path-to-file>.sql.gz
Create settings.local.php
and include database credentials for the migration database and make
sure the database is there:
// Migrate database.
$databases['migrate']['default'] = array (
'database' => 'migrate',
'username' => $databases['default']['default']['username'],
'password' => $databases['default']['default']['password'],
'prefix' => '',
'driver' => 'mysql',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'host' => $databases['default']['default']['host'],
'port' => $databases['default']['default']['port'],
);
If you need to adapt the charset of the migrate
database, please see
this document.
A few taxonomy machine names were renamed:
-
vocabulary_1
toforums
-
vocabulary_2
toscreenshots
-
vocabulary_3
tomodule_categories
-
vocabulary_5
todrupal_version
-
vocabulary_6
tocore_compatibility
-
vocabulary_7
torelease_type
-
vocabulary_9
toissue_tags
-
vocabulary_31
topage_status
-
vocabulary_34
tofront_page_news
-
vocabulary_38
toaudience
-
vocabulary_44
tomaintenance_status
-
vocabulary_46
todevelopment_status
-
vocabulary_48
toservices
-
vocabulary_50
tosectors
-
vocabulary_52
tolocations
-
vocabulary_54
tokeywords
-
vocabulary_56
tolevel
-
vocabulary_58
tolicense
-
vocabulary_60
tobook_availability
-
vocabulary_62
tobook_format
All the fields that started with taxonomy_vocabulary_
where renamed to field_
plus the above mapping.
Migrations
Get a full list of (default) migrations available:
ddev drush ms --group=drupalorg_migrate
See the file scripts/migrations.sh
to know all the migrations
and their order.
If you don't follow the order, make sure you append --execute-dependencies
.
Files and media
Copy files (if only subfolders needed then adjust paths):
scp -r <your-username>@devwww.drupalsystems.org:/var/www/dev/<your-username>-drupal.dev.devdrupal.org/htdocs/files/project-images web/files/d7-files/files/project-images
Migrations to run (included in <root>/scripts/migrations.sh
:
ddev drush mim FILES
Implemented Hacks
Missing files
Files are intentionally NOT being migrated right now. The following command was run to disable media migrations:
drush pm:uninstall media_migration
Additionally, the migrate_devel_file_copy module is installed. This generates file stubs rather than importing real files. To change this, disable migrate_devel_file_copy and rerun the file migrations.
Disabled Migrations
d7_field_collection and d7_field_collection_revisions
We’ve “cheated” by removing the d7_field_collection and d7_field_collection_revisions migrations for users, thereby bypassing the problematic d7_field_collection:user:user:field_organizations migration and allowing the other "User accounts" migrations to continue forward.
However, the d7_field_collection:user:user:field_organizations is largely complete. There are 5 "missing rows."
This was done by applying the following patch to paragraphs:
diff --git a/web/modules/contrib/paragraphs/src/Plugin/migrate/D7FieldCollectionItemDeriver.php b/web/modules/contrib/paragraphs/src/Plugin/migrate/D7FieldCollectionItemDeriver.php
index 054c941d..3e945441 100644
--- a/web/modules/contrib/paragraphs/src/Plugin/migrate/D7FieldCollectionItemDeriver.php
+++ b/web/modules/contrib/paragraphs/src/Plugin/migrate/D7FieldCollectionItemDeriver.php
@@ -98,6 +98,8 @@ public function getDerivativeDefinitions($base_plugin_definition) {
$derivatives = array_reduce($statement->fetchAll(), function (array $carry, $row) {
$fci_data = unserialize($row->data);
$carry[$row->entity_type][$row->bundle][$row->field_name] = $fci_data['label'];
+ // @todo Remove this!
+ unset($carry['user']);
return $carry;
}, []);
}
user
In order to drastically improve the speed of user imports, the following temporary change was made:
diff --git a/web/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php b/web/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php
index 8adbd57f..2e9353a8 100644
--- a/web/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php
+++ b/web/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php
@@ -14,6 +14,9 @@ class UniqueFieldValueValidator extends ConstraintValidator {
* {@inheritdoc}
*/
public function validate($items, Constraint $constraint) {
+ // Temp hack.
+ return;
+
if (!$item = $items->first()) {
return;
}
This disables the check for user uniqueness and does generate some errors.