Recent content

Overview
The move to Drupal 9 was a far better experience, although not without bugs. Fortunately googling and some database foo fixed them.

Strategy
There is no migration process for this upgrade. Therefore I will clone the environments to a new location and then upgrade that copy in situ. Once the upgrade is complete I will redirect the web server to the new location.

I will do most of this from the command line. The exception are a few administrative tasks post-install.

Reference:
https://www.drupal.org/docs/upgrading-drupal/drupal-8-and-higher

1. CLONE DATABASE
I've been using the 'old_user' account for a long time. Time to generalize:


psql template1 postgres
CREATE USER new_user WITH PASSWORD 'password';
CREATE DATABASE new_db WITH TEMPLATE old_db OWNER new_user ENCODING UNICODE;

The permissions will be a mess. Let's fix them:

psql new_db postgres
GRANT old_user TO new_user;
REVOKE ALL PRIVILEGES ON DATABASE new_db FROM old_user;
REASSIGN OWNED BY old_user TO new_user;

Check that the move to the new user was successful:

\dt
\ds
\dv

Everything should reference the new user and the old user should not be present.

2. CLONE DRUPAL 8
Put Drupal 8 into maintenance mode.


cd install_dir
cp -aR 8 9
chown -R www-data.www-data 9
cd install_dir/9/web/sites/default

Update settings.php to point to the new database.

3. CLONE APACHE
Update apache:

cd /etc/apache2/sites-available
cp drupal8.conf drupal9.conf

Update contents of drupal9.conf to reflect the new install_dir.
I also removed obsolete Order and Allow directives.


a2dissite drupal8
a2ensite drupal9
systemctl restart apache2

4. PREP FOR UPGRADE TO DRUPAL 9
Verify no updates needed (for Drupal 8 install) at: www.teramari.us/update.php.

Upgrade drush to version 10:

cd install_dir/9
composer require 'drush/drush:^10'

Reference:
https://www.drush.org/13.x/install/#drupal-compatibility

Open access to the config files:

chmod 777 web/sites/default
chmod 666 web/sites/default/*settings.php
chmod 666 web/sites/default/*services.yml

5. DRUPAL 9 UPGRADE

cd install_dir/9/
composer require 'drupal/core-recommended:^9' 'drupal/core-composer-scaffold:^9' 'drupal/core-project-message:^9' --update-with-dependencies --no-update
composer require 'drupal/core-dev:^9' --dev --update-with-dependencies --no-update
composer update

Updating the database did run into issues. fortunately this release is so old all the workarounds are on the web:

psql new_db new_user
DROP SEQUENCE "users_uid_seq2"; (may error)
ALTER SEQUENCE "users_uid_seq" RENAME TO "users_uid_seq2";

'composer update' automaitcally queues a bunch of database updates. Now run this to execute the queue:

cd install_dir/9
vendor/bin/drush updatedb

Reference:
https://www.drupal.org/project/drupal/issues/3275916

6. DRUPAL 9 POST-INSTALL
User accounts and passwords should be unchanged from Drupal 8.

Lock down the config files:

chmod 755 web/sites/default
chmod 644 web/sites/default/*settings.php
chmod 644 web/sites/default/*services.yml

Setup upgrade_status module:

composer require drupal/upgrade_status

Setup composer_deploy module:

cd install_dir/9/
composer require 'drupal/composer_deploy:^1.0'

Browse to: https://www.teramari.us/admin/reports/upgrade-status.

Clear any issues there _if they make sense_ (since we are not actually upgrading to Drupal 10):
1. remove unused deprecated themes
2. remove unused deprecated modules
3. update database
4. enable this PostgreSQL extension on the database:

psql new_db new_user
CREATE EXTENSION pg_trgm;

Browse to: www.teramari.us/admin/reports/status and clear the errors (they seem to vary between installs).
5. Install uploadprogress package:

apt-get install php-uploadprogress

6. Install PHP ACPU package:

apt-get install php7.4-apcu

7. I also installed the following modules and themes:

composer require 'drupal/login_security:^2.0'
composer require 'drupal/password_policy:^4.0'
composer require 'drupal/flood_control:^2.3'
composer require 'drupal/captcha:^2.0'
composer require 'drupal/security_review:^2.0'
composer require 'drupal/tfa:^1.12'
composer require 'drupal/seckit:^2.0'
composer require 'drupal/recaptcha:^3.2'
composer require 'drupal/nodeaccess:^2.0@alpha'
composer require 'drupal/linkchecker:^2.0'
composer require 'drupal/honeypot:^2.1'
composer require 'drupal/extlink:^1.7'
composer require 'drupal/google_analytics:^4.0'
composer require 'drupal/site_audit:^4.0'
composer require 'drupal/webprofiler:^9.0'
composer require 'drupal/db_maintenance:^3.0@RC'
composer require 'drupal/cache_control_override:^1.1'
composer require 'drupal/insert:^2.1'
composer require 'drupal/webp:^1.0@RC'
composer require 'drupal/imageapi_optimize:^4.0'
composer require drupal/memcache
composer require 'drupal/bootstrap5:^3.0'
composer require 'drupal/tara:^10.1'

And then reset the permissions back to www-data:

chown -R www-data.www-data *

Exit maintenance mode.

Reference:
https://www.drupal.org/project/upgrade_status

7. TEST
Write up the upgrade notes (this doc) as a blog post. It should post with no errors.

Planning
Upgrades to Drupal 10 and Drupal 11 will come in 2026 along with an upgrade to Debian 12 and Debian 13.

For now I will research improvements to security and performance on Drupal 9. I will also spend some time getting to know the new Drupal features and functionality.