From 36e95d36f7a19009cd73b2266f26572c051f74ab Mon Sep 17 00:00:00 2001 From: Finley Ghosh Date: Sun, 10 Aug 2025 18:46:35 +1000 Subject: [PATCH] Adding a new migration script --- Dockerfile_stg | 2 ++ deploy/deploy-stg.sh | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Dockerfile_stg b/Dockerfile_stg index b8aedb4e..2308b091 100644 --- a/Dockerfile_stg +++ b/Dockerfile_stg @@ -48,5 +48,7 @@ RUN mkdir /var/www/cmc-sales/app/tmp/logs RUN chmod -R 755 /var/www/cmc-sales/app/tmp RUN chmod +x /var/www/cmc-sales/run_vault.sh +# Ensure CakePHP tmp directory is writable by web server +RUN chmod -R 777 /var/www/cmc-sales/app/tmp # By default, simply start apache. CMD /usr/sbin/apache2ctl -D FOREGROUND diff --git a/deploy/deploy-stg.sh b/deploy/deploy-stg.sh index afdb72e8..e5ec8f46 100755 --- a/deploy/deploy-stg.sh +++ b/deploy/deploy-stg.sh @@ -79,6 +79,23 @@ ENVEOF # Check containers docker compose -f docker-compose.stg.yml ps + echo "Creating migration runner script..." + cat > /home/cmc/run_all_migrations.sh <<'EOF' +#!/bin/bash +set -e +SQL_DIR="/home/cmc/cmc-sales-staging/sql/schema" +DB_USER="cmc" +DB_PASS="xVRQI&cA?7AU=hqJ!%au" +DB_NAME="cmc" +DB_HOST="127.0.0.1" + +for sqlfile in "$SQL_DIR"/*.sql; do + echo "Running migration: $sqlfile" + mariadb -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" < "$sqlfile" +done +echo "All migrations applied." +EOF + chmod +x /home/cmc/run_all_migrations.sh echo "Creating restore script for database from backups..." # Create restore script for database from backups cat > /home/cmc/restore_db_from_backup.sh <<'EOF'