Drupal 9 Upgrade Options

Lightning Talk DACH User Group

Jürgen Haas - @jurgenhaas

8. April 2021

Task

  • Drupal 8 site has a complex data model
    • 20ish content entity types
    • over 70 bundles
    • over 150 fields (60 of which are entity-refs)
    • over 100 display modes
    • over 1.600 config files
    • over 230 enabled modules
  • Data model changes/improvements for
    • 50% of the entity types
    • 5% of the fields

Options for Drupal 9 Upgrade

  1. composer upgrade and drush updatedb
  2. Build site from scratch and use Drupal migrate for content
  3. Or else?

Custom approach

#!/bin/bash

composer update
drush -y site:install bs_portal
drush -y pm:enable bs_inventory_real_estate bs_dashboard bs_content_node_blog bs_content_node_event bs_content_node_incident bs_content_node_info bs_content_node_internal bs_content_node_page analog_digital_clock block_content block_styles colorbox color_field config_translation contact content_translation digital_signage_framework digital_signage_custom_platform draggableviews endroid_qr_code language helpdesk_zendesk layout_builder_styles locale maxlength mobimo_free_properties opentransportdata_swiss pf_onesignal redirect responsive_favicons readonly_field_widget rest signageos simple_sitemap title wayfinding wayfinding_digital_signage webform bs_shop bs_relocation_calendar
drush -y theme:enable custom_theme
prepare_and_import_config.sh
drush @default.production sql:dump --data-only --result-file=/tmp/data.sql --extra-dump=--complete-insert --tables-key=drupal9
scp livehost:/tmp/data.sql .
prepare_sql.sh
drush sql:query --file=../data.sql

drush @default.production sql:dump --result-file=/tmp/maps.sql --extra-dump=--complete-insert --tables-list="migrate_map_*,migrate_message_*"
scp livehost:/tmp/maps.sql .
sed -i "s/migrate_map_users/migrate_map_bs_user/g" maps.sql
sed -i "s/migrate_message_users/migrate_message_bs_user/g" maps.sql
drush sql:query --file=../maps.sql
drush php:script cleanup --script-path=../config

drush migrate:import --all

Conclusion

  1. Build Drupal 9 site from scratch - cleans legacy xyz’s
  2. Update selected config yaml files and import them
  3. Dump, modify and import selected DB tables from live site
  4. Import and update migration maps
  5. Migrate import updated external content