Migrates content from sites built on https://github.com/os2loop/profile to sites built on https://github.com/os2loop/os2loop.
Define the source database with key migrate (cf.
https://www.drupal.org/docs/upgrading-drupal/upgrade-using-drush#s-define-the-source-database):
$databases['migrate']['default'] = [
'database' => 'db',
'username' => 'db',
'password' => 'db',
'prefix' => '',
'host' => '0.0.0.0',
'port' => '55008',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
];Check that you can connect to your migrate database.
vendor/bin/drush sql:query --database=migrate 'SHOW TABLES'Clean up source database:
# Delete non-existing comments with upvotes.
vendor/bin/drush sql:query --database=migrate 'DELETE FROM flagging WHERE fid = 1 AND entity_id NOT IN (SELECT cid FROM comment)'
# Delete flagging of non-existing messages;
vendor/bin/drush sql:query --database=migrate 'DELETE FROM flagging WHERE fid = 2 AND entity_id NOT IN (SELECT mid FROM message)'
# Delete subscriptions on non-existing nodes.
vendor/bin/drush sql:query --database=migrate 'DELETE FROM flagging WHERE fid = 3 AND entity_id NOT IN (SELECT nid FROM node)'
# Delete subscriptions on non-existing taxonomies.
vendor/bin/drush sql:query --database=migrate 'DELETE FROM flagging WHERE fid = 4 AND entity_id NOT IN (SELECT tid FROM taxonomy_term_data)'Install the OS2Loop Migrate module:
# Install dev packages.
composer config repositories.os2loop/os2loop_migrate vcs https://github.com/itk-dev/os2loop_migrate
composer require --dev os2loop/os2loop_migrate:dev-develop
vendor/bin/drush --yes pm:enable os2loop_migrateAfter completing the migration, you should uninstall the modules used for the migration (this will also remove the migration configuration):
vendor/bin/drush --yes pm:uninstall migrate
# Undo changes to composer files.
git checkout composer.*vendor/bin/drush cache:rebuild
vendor/bin/drush search-api:reset-tracker os2loop_search_db_index
vendor/bin/drush search-api:rebuild-tracker os2loop_search_db_index
vendor/bin/drush search-api:index os2loop_search_db_indexFinally, i.e. when you're completely done with the migration, you can remove the
migrations tables (prefixed with migrate_) from the database:
for t in $(vendor/bin/drush sql:query "SHOW TABLES LIKE 'migrate\_%'"); do vendor/bin/drush sql:query "DROP TABLE $t"; doneThe migration assumes that all media files are available in the migrate folder:
mkdir -p migrate/sites/default
rsync --archive --compress --delete «old site root»/sites/default/files migrate/sites/defaultMigrate all Loop content:
vendor/bin/drush migrate:import --tag=os2loopAfter running all migrations, complete the steps Create media entities and connect to content:
# Create media entities and connect to content
vendor/bin/drush os2loop:migrate:files-to-mediaOptionally, complete the steps in Rich text in questions and Empty question titles.
The actual migration of content should be performed in the following order.
After deploying migrated content (database and files) to the final site, you
should run these drush commands on the deployed database (cf.
https://www.drupal.org/project/convert_media_tags_to_markup):
drush php:eval "\Drupal\convert_media_tags_to_markup\ConvertMediaTagsToMarkup\DbReplacer::instance()->replaceAll('node', 'os2loop_documents_collection', FALSE)"
drush php:eval "\Drupal\convert_media_tags_to_markup\ConvertMediaTagsToMarkup\DbReplacer::instance()->replaceAll('node', 'os2loop_documents_document', FALSE)"
drush php:eval "\Drupal\convert_media_tags_to_markup\ConvertMediaTagsToMarkup\DbReplacer::instance()->replaceAll('node', 'os2loop_page', FALSE)"
drush php:eval "\Drupal\convert_media_tags_to_markup\ConvertMediaTagsToMarkup\DbReplacer::instance()->replaceAll('node', 'os2loop_question', FALSE)"vendor/bin/drush migrate:import upgrade_d7_filevendor/bin/drush migrate:import upgrade_d7_taxonomy_term_subject
vendor/bin/drush migrate:import upgrade_d7_taxonomy_term_keyword
vendor/bin/drush migrate:import upgrade_d7_taxonomy_term_professionvendor/bin/drush migrate:import upgrade_d7_uservendor/bin/drush migrate:import upgrade_d7_node_complete_page
vendor/bin/drush migrate:import upgrade_d7_node_complete_external_sources
vendor/bin/drush migrate:import upgrade_d7_node_complete_post
vendor/bin/drush migrate:import upgrade_d7_node_complete_loop_documents_document
vendor/bin/drush migrate:import upgrade_d7_node_complete_loop_documents_collectionIf the loop_post_wysiwyg module is enabled in the migration source site, all questions must be updated to use rich text:
vendor/bin/drush sql:query "UPDATE node__os2loop_question_content SET os2loop_question_content_format ='os2loop_question_rich_text'"
vendor/bin/drush cache:rebuildIf rich text should be enabled for new questions, go to
/admin/config/os2loop/os2loop_question/settings and check “Enable rich text in
questions” or run
vendor/bin/drush --yes config:set os2loop_question.settings enable_rich_text 1vendor/bin/drush os2loop:migrate:files-to-mediaMigrated questions use (part of) their body as title. To set empty titles, run the following commands:
vendor/bin/drush sql:query "UPDATE node_field_data AS node JOIN node_field_revision AS revision ON node.nid = revision.nid and node.vid = revision.vid SET node.title = '', revision.title = '' WHERE node.type = 'os2loop_question'"
vendor/bin/drush cache:rebuildvendor/bin/drush migrate:import upgrade_d7_commentvendor/bin/drush migrate:import upgrade_d7_flaggingIf a migration gets stuck:
vendor/bin/drush migrate:reset-statusReverting a migration:
vendor/bin/drush migrate:rollbackMigration status:
vendor/bin/drush migrate:status --tag="Drupal 7"Migration messages:
vendor/bin/drush migrate:messages