2025-08-10 02:21:37 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
set -e
|
|
|
|
|
SQL_DIR="/home/cmc/cmc-sales-staging/go-app/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
|
2025-08-10 05:35:26 -07:00
|
|
|
# Skip files starting with ignore_
|
|
|
|
|
if [[ $(basename "$sqlfile") == ignore_* ]]; then
|
2025-08-10 02:21:37 -07:00
|
|
|
echo "Skipping ignored migration: $sqlfile"
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
echo "Running migration: $sqlfile"
|
2025-08-10 05:35:26 -07:00
|
|
|
docker cp "$sqlfile" cmc-db:/tmp/migration.sql
|
|
|
|
|
docker exec cmc-db sh -c "mariadb -u $DB_USER -p'$DB_PASS' $DB_NAME < /tmp/migration.sql"
|
2025-08-10 02:21:37 -07:00
|
|
|
done
|
|
|
|
|
echo "All migrations applied."
|