From 81997c8e3e20c53d32f68bef1298e827a5c9afd6 Mon Sep 17 00:00:00 2001 From: Shaun Drong Date: Wed, 24 Jun 2026 11:08:47 -0700 Subject: [PATCH 1/5] Add re-import commands for local Drupal changes Added commands to re-import local Drupal changes after clearing the database. --- local/etc/uceap.d/devcontainer_reset_db.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/local/etc/uceap.d/devcontainer_reset_db.sh b/local/etc/uceap.d/devcontainer_reset_db.sh index ef1b5bc..c5459b5 100644 --- a/local/etc/uceap.d/devcontainer_reset_db.sh +++ b/local/etc/uceap.d/devcontainer_reset_db.sh @@ -61,6 +61,11 @@ function devcontainer_reset_db() { _cwd_workspace drush cache-rebuild + echo "Re-import local Drupal changes..." + _cwd_workspace + drush updb + drush cim -y + echo "Database reset complete!" } From b7fad62bdfdb13b608122d657c23b4d1fb863dca Mon Sep 17 00:00:00 2001 From: Shaun Drong Date: Wed, 24 Jun 2026 19:38:59 -0700 Subject: [PATCH 2/5] Update local/etc/uceap.d/devcontainer_reset_db.sh Co-authored-by: Brandt Kurowski --- local/etc/uceap.d/devcontainer_reset_db.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/local/etc/uceap.d/devcontainer_reset_db.sh b/local/etc/uceap.d/devcontainer_reset_db.sh index c5459b5..dede785 100644 --- a/local/etc/uceap.d/devcontainer_reset_db.sh +++ b/local/etc/uceap.d/devcontainer_reset_db.sh @@ -63,8 +63,7 @@ function devcontainer_reset_db() { echo "Re-import local Drupal changes..." _cwd_workspace - drush updb - drush cim -y + drush deploy echo "Database reset complete!" } From 4fa637241df0dd5b29fb10d112dd631f0842111b Mon Sep 17 00:00:00 2001 From: Shaun Drong Date: Thu, 25 Jun 2026 12:31:35 -0700 Subject: [PATCH 3/5] Implement skip-deploy option in reset_db script Added option to skip deployment during database reset. --- local/etc/uceap.d/devcontainer_reset_db.sh | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/local/etc/uceap.d/devcontainer_reset_db.sh b/local/etc/uceap.d/devcontainer_reset_db.sh index dede785..56192d1 100644 --- a/local/etc/uceap.d/devcontainer_reset_db.sh +++ b/local/etc/uceap.d/devcontainer_reset_db.sh @@ -2,6 +2,23 @@ function devcontainer_reset_db() { # Detect the compose project by inspecting the current container CURRENT_CONTAINER=$(hostname) echo "Running from container: $CURRENT_CONTAINER" + local skip_deploy=false + + # Loop through all arguments passed to the function + while [[ $# -gt 0 ]]; do + case "$1" in + -sd|--skip-deploy) + skip_deploy=true + return 0 + ;; + *) + echo "Unknown option: $1" >&2 + return 1 + ;; + case_end + esac + done + # Get the compose project name from the current container's labels COMPOSE_PROJECT=$(docker inspect "$CURRENT_CONTAINER" --format '{{index .Config.Labels "com.docker.compose.project"}}' 2>/dev/null) @@ -61,10 +78,12 @@ function devcontainer_reset_db() { _cwd_workspace drush cache-rebuild - echo "Re-import local Drupal changes..." - _cwd_workspace - drush deploy - + # Check if skip-deploy not passed as option and run deploy + if [ "$skip_deploy" = false ]; then + echo "Re-import local Drupal changes..." + _cwd_workspace + drush deploy + fi echo "Database reset complete!" } From 7b14aa0ec9c779c9c4ea0509f7a239371e5c0aeb Mon Sep 17 00:00:00 2001 From: Shaun Drong Date: Tue, 30 Jun 2026 17:51:13 +0000 Subject: [PATCH 4/5] Update case loop logic, scoped vars to local, return 1 on step failures --- local/etc/uceap.d/devcontainer_reset_db.sh | 45 +++++++++++++--------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/local/etc/uceap.d/devcontainer_reset_db.sh b/local/etc/uceap.d/devcontainer_reset_db.sh index 56192d1..c42b673 100644 --- a/local/etc/uceap.d/devcontainer_reset_db.sh +++ b/local/etc/uceap.d/devcontainer_reset_db.sh @@ -1,23 +1,27 @@ function devcontainer_reset_db() { # Detect the compose project by inspecting the current container + local CURRENT_CONTAINER + local COMPOSE_PROJECT + local WORKSPACE_NAME + local CONTAINER_NAME + local VOLUME_NAME CURRENT_CONTAINER=$(hostname) echo "Running from container: $CURRENT_CONTAINER" local skip_deploy=false # Loop through all arguments passed to the function - while [[ $# -gt 0 ]]; do - case "$1" in - -sd|--skip-deploy) - skip_deploy=true - return 0 - ;; - *) - echo "Unknown option: $1" >&2 - return 1 - ;; - case_end - esac - done + while [[ $# -gt 0 ]]; do + case "$1" in + -sd|--skip-deploy) + skip_deploy=true + shift + ;; + *) + echo "Unknown option: $1" >&2 + return 1 + ;; + esac + done # Get the compose project name from the current container's labels @@ -60,15 +64,15 @@ function devcontainer_reset_db() { echo "Found volume: $VOLUME_NAME" # Stop and remove the container - docker compose -p "$COMPOSE_PROJECT" -f .devcontainer/docker-compose.yml stop mariadb - docker compose -p "$COMPOSE_PROJECT" -f .devcontainer/docker-compose.yml rm -f mariadb + docker compose -p "$COMPOSE_PROJECT" -f .devcontainer/docker-compose.yml stop mariadb || return 1 + docker compose -p "$COMPOSE_PROJECT" -f .devcontainer/docker-compose.yml rm -f mariadb || return 1 # Remove the volume echo "Removing volume: $VOLUME_NAME" - docker volume rm "$VOLUME_NAME" + docker volume rm "$VOLUME_NAME" || return 1 # Start the container with a fresh volume - docker compose -p "$COMPOSE_PROJECT" -f .devcontainer/docker-compose.yml up -d mariadb + docker compose -p "$COMPOSE_PROJECT" -f .devcontainer/docker-compose.yml up -d mariadb || return 1 echo "Waiting for database to be ready..." sleep 5 @@ -76,13 +80,13 @@ function devcontainer_reset_db() { # Clear Drupal cache since the database was reset echo "Clearing Drupal cache..." _cwd_workspace - drush cache-rebuild + drush cache-rebuild || return 1 # Check if skip-deploy not passed as option and run deploy if [ "$skip_deploy" = false ]; then echo "Re-import local Drupal changes..." _cwd_workspace - drush deploy + drush deploy || return 1 fi echo "Database reset complete!" } @@ -95,6 +99,7 @@ Resets the devcontainer database to its original state by recreating the mariadb ``` bash uceap devcontainer-reset-db +uceap devcontainer-reset-db --skip-deploy ``` ## Description @@ -105,6 +110,8 @@ This command is faster than `uceap refresh-content` when you only need to reset 2. Removing the anonymous volume that contains the modified database data 3. Recreating the container from the image with baked-in seed data +Use `--skip-deploy` to skip `drush deploy` after the reset. + This is useful after running e2e tests that modify the database (e.g., submitting an application). The database container image has seed data pre-baked, so resetting to a clean state is much faster than downloading and importing a SQL dump from Pantheon. **Note:** This command only works in devcontainers and will not work in CI or other environments. From 955dd88e9d144eed2bbe66ec9937ad6965d810a9 Mon Sep 17 00:00:00 2001 From: Shaun Drong Date: Wed, 1 Jul 2026 11:26:42 -0700 Subject: [PATCH 5/5] Update drush command and webroot variables in the db-rebuild.sh command used by the Refresh data task I updated the uceap devcontainer-reset-db command, but the actual refresh data task in vs code uses the /usr/bin/db-rebuild.sh script. This script was failing to find the correct web root(pointing to our very old LANDO_WEBROOT) and wasn't finding the drush command once in the web root. This updates that script to work with the container and as such fix the config import after running the vs code task. --- local/bin/db-rebuild.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/local/bin/db-rebuild.sh b/local/bin/db-rebuild.sh index 11805fc..79106de 100755 --- a/local/bin/db-rebuild.sh +++ b/local/bin/db-rebuild.sh @@ -6,7 +6,9 @@ USER=${DB_USER:-${MYSQL_USER:-root}} PASSWORD=${DB_PASSWORD:-${MYSQL_PASSWORD:-}} DATABASE=${DB_NAME:-${MYSQL_DATABASE:-database}} PORT=${DB_PORT:-${MYSQL_TCP_PORT:-3306}} -WEBROOT=${LANDO_WEBROOT:-$(dirname $(dirname $(realpath $0)))} +WEBROOT=${WORKSPACE_FOLDER:-$(dirname $(dirname $(realpath $0)))} +DRUSH_BIN=${WEBROOT}/vendor/bin/drush +DRUSH=${DRUSH_BIN:-drush} DRUSHTASK=${DRUSH_TASK:-deploy} TERMINUSENV=${TERMINUS_ENV:-dev} @@ -157,4 +159,4 @@ echo "Import completed with status code $?" # update db with latest code/config changes echo "Running drush:$DRUSHTASK to update DB with latest configs and baseline migrations." -eval "cd $WEBROOT && drush $DRUSHTASK" \ No newline at end of file +eval "cd $WEBROOT && $DRUSH $DRUSHTASK"