deployment fix?
This commit is contained in:
18
deploy.sh
18
deploy.sh
@@ -57,22 +57,8 @@ fi
|
||||
|
||||
# Apply database migrations
|
||||
echo -e "${YELLOW}🗄️ Applying database migrations...${NC}"
|
||||
if [ -f "backend/create_backup_jobs_table.sql" ]; then
|
||||
echo "Applying backup_jobs table migration..."
|
||||
|
||||
# Get list of databases
|
||||
DATABASES=$(docker-compose exec -T postgres psql -U storycove -lqt | cut -d \| -f 1 | grep -E '^ storycove' | sed 's/^[ \t]*//')
|
||||
|
||||
# Apply migration to each database
|
||||
for DB_NAME in $DATABASES; do
|
||||
echo " - Applying to database: $DB_NAME"
|
||||
docker-compose exec -T postgres psql -U storycove -d "$DB_NAME" < backend/create_backup_jobs_table.sql 2>&1 | grep -E "(CREATE|ERROR)" || true
|
||||
done
|
||||
|
||||
echo -e "${GREEN}✅ Database migrations applied${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ No migration files found, skipping...${NC}"
|
||||
fi
|
||||
docker-compose run --rm migrations
|
||||
echo -e "${GREEN}✅ Database migrations applied${NC}"
|
||||
|
||||
# Check if Solr is ready
|
||||
echo -e "${YELLOW}🔍 Checking Solr health...${NC}"
|
||||
|
||||
@@ -65,34 +65,40 @@ services:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- storycove-network
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U storycove -d storycove"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
migrations:
|
||||
image: postgres:15-alpine
|
||||
depends_on:
|
||||
- postgres
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- ./backend/create_backup_jobs_table.sql:/migrations/create_backup_jobs_table.sql:ro
|
||||
networks:
|
||||
- storycove-network
|
||||
environment:
|
||||
- PGPASSWORD=${DB_PASSWORD}
|
||||
entrypoint: /bin/sh
|
||||
command: >
|
||||
-c "
|
||||
echo 'Waiting for postgres to be ready...';
|
||||
sleep 5;
|
||||
echo 'Applying migrations to all databases...';
|
||||
echo '🗄️ Applying database migrations...';
|
||||
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...\";
|
||||
if psql -h postgres -U storycove -lqt | cut -d '|' -f 1 | grep -qw \$$DB; then
|
||||
echo \" ✓ Applying migration to \$$DB...\";
|
||||
psql -h postgres -U storycove -d \$$DB -f /migrations/create_backup_jobs_table.sql > /dev/null 2>&1 || true;
|
||||
fi;
|
||||
done;
|
||||
echo 'All migrations complete!';
|
||||
echo '✅ Migrations complete!';
|
||||
sleep infinity;
|
||||
"
|
||||
restart: "no"
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
max_attempts: 1
|
||||
|
||||
|
||||
solr:
|
||||
|
||||
Reference in New Issue
Block a user