Adding a new migration script
This commit is contained in:
parent
851a1f8ac6
commit
36e95d36f7
|
|
@ -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 -R 755 /var/www/cmc-sales/app/tmp
|
||||||
RUN chmod +x /var/www/cmc-sales/run_vault.sh
|
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.
|
# By default, simply start apache.
|
||||||
CMD /usr/sbin/apache2ctl -D FOREGROUND
|
CMD /usr/sbin/apache2ctl -D FOREGROUND
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,23 @@ ENVEOF
|
||||||
# Check containers
|
# Check containers
|
||||||
docker compose -f docker-compose.stg.yml ps
|
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..."
|
echo "Creating restore script for database from backups..."
|
||||||
# Create restore script for database from backups
|
# Create restore script for database from backups
|
||||||
cat > /home/cmc/restore_db_from_backup.sh <<'EOF'
|
cat > /home/cmc/restore_db_from_backup.sh <<'EOF'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue