From 84340751775070a05ea1f841da73c25a2de2bf5f Mon Sep 17 00:00:00 2001 From: Brandt Kurowski Date: Thu, 12 Nov 2026 16:06:33 +0000 Subject: [PATCH] Run database updates before any cache rebuild on TEST/LIVE deploys Deploying ucdcweb2 to TEST failed after a Drupal core upgrade from 11.1 to 11.4: cache-rebuild ran before drush deploy, so the new core code rebuilt its router against the live database's old schema and hit "Unknown column 'alias'". The earlier fix only covered major upgrades, but minor releases change the schema too. drush deploy already runs updatedb before config:import and cache:rebuild, so drop the cache-rebuild in front of it, the pre-deploy env:clear-cache (which fails the same way after a stalled deploy), and the major-version detection that only existed to work around them. Co-Authored-By: Claude Opus 5.5 --- local/etc/uceap.d/_pantheon_deploy.sh | 46 ++++----------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/local/etc/uceap.d/_pantheon_deploy.sh b/local/etc/uceap.d/_pantheon_deploy.sh index 7b5909c..5e97125 100644 --- a/local/etc/uceap.d/_pantheon_deploy.sh +++ b/local/etc/uceap.d/_pantheon_deploy.sh @@ -1,51 +1,17 @@ function _pantheon_deploy() { _assert_terminus_vars - local major_upgrade=false - if _drupal_major_upgrade_pending; then - major_upgrade=true - fi terminus drush -- state-set system.maintenance_mode TRUE - # env:clear-cache runs a cache rebuild, which fails if a stalled deploy left - # the new code on the old schema, so it waits until after the updates. - if ! $major_upgrade; then - terminus env:clear-cache - fi + # No cache clear before env:deploy: if an earlier deploy stalled, the target + # already has new code on the old schema, and a cache rebuild there can fail + # before the database updates get a chance to run. terminus env:deploy $deploy_args - if $major_upgrade; then - # A new major version of core can't rebuild its cache against the old - # schema, so the database updates must run before cache-rebuild. - terminus drush -- updatedb -y - fi _pantheon_complete_deployment } -# Succeeds when the code being deployed runs a newer Drupal major version than -# the database that will end up in the target environment. -function _drupal_major_upgrade_pending() { - local code_env db_env code_version db_version - case "$TERMINUS_ENV" in - test) code_env="dev" ;; - live) code_env="test" ;; - *) return 1 ;; - esac - # --sync-content replaces the target's database with LIVE's. - if [[ " $deploy_args " == *" --sync-content "* ]]; then - db_env="live" - else - db_env="$TERMINUS_ENV" - fi - code_version=$(terminus drush "$TERMINUS_SITE.$code_env" -- status --field=drupal-version) || return 1 - db_version=$(terminus drush "$TERMINUS_SITE.$db_env" -- status --field=drupal-version) || return 1 - echo "Drupal core: $code_version on $code_env, $db_version on $db_env" - if [ "${code_version%%.*}" -gt "${db_version%%.*}" ]; then - echo "Major version upgrade detected; database updates will run before cache-rebuild." - return 0 - fi - return 1 -} - function _pantheon_complete_deployment() { - terminus drush -- cache-rebuild + # drush deploy runs updatedb before config:import and cache:rebuild. Don't + # rebuild caches before it: new core code can't rebuild against a schema + # its update hooks haven't migrated yet (e.g. 11.1 -> 11.4 adds router.alias). terminus drush -- deploy sleep 60 terminus drush -- state-set system.maintenance_mode FALSE