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