db migration

This commit is contained in:
Stefan Hardegger
2025-10-20 12:43:58 +02:00
parent 6a38189ef0
commit 70599083b8
2 changed files with 73 additions and 0 deletions

View File

@@ -66,6 +66,34 @@ services:
networks:
- storycove-network
migrations:
image: postgres:15-alpine
depends_on:
- postgres
volumes:
- ./backend/create_backup_jobs_table.sql:/migrations/create_backup_jobs_table.sql:ro
networks:
- storycove-network
entrypoint: /bin/sh
command: >
-c "
echo 'Waiting for postgres to be ready...';
sleep 5;
echo 'Applying migrations to all databases...';
for DB in storycove storycove_afterdark storycove_clas storycove_secret; do
echo \"Checking if database \$$DB exists...\";
if PGPASSWORD=${DB_PASSWORD} psql -h postgres -U storycove -lqt | cut -d \\| -f 1 | grep -qw \$$DB; then
echo \"Applying migration to \$$DB...\";
PGPASSWORD=${DB_PASSWORD} psql -h postgres -U storycove -d \$$DB -f /migrations/create_backup_jobs_table.sql;
echo \"✓ Migration applied to \$$DB\";
else
echo \"⚠ Database \$$DB does not exist, skipping...\";
fi;
done;
echo 'All migrations complete!';
"
restart: "no"
solr:
build: