Verbessere Docker-Migration: Entrypoint mit Baseline-Fallback und aktualisiere baseline-migrations.sh
This commit is contained in:
@@ -37,6 +37,4 @@ services:
|
|||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
start_period: 40s
|
start_period: 40s
|
||||||
# Run migrations and start server (auto-baseline on first run if needed)
|
# docker-entrypoint.sh handles migrations and server startup (with baseline fallback)
|
||||||
command: >
|
|
||||||
sh -c "npx prisma migrate deploy || (echo 'Baselining existing database...' && sh scripts/baseline-migrations.sh && npx prisma migrate deploy) && node server.js"
|
|
||||||
|
|||||||
@@ -14,5 +14,10 @@ npx prisma migrate resolve --applied "20251123083856_add_rating_system"
|
|||||||
npx prisma migrate resolve --applied "20251123140527_add_subtitles"
|
npx prisma migrate resolve --applied "20251123140527_add_subtitles"
|
||||||
npx prisma migrate resolve --applied "20251123181922_add_release_year"
|
npx prisma migrate resolve --applied "20251123181922_add_release_year"
|
||||||
npx prisma migrate resolve --applied "20251123204000_fix_cascade_delete"
|
npx prisma migrate resolve --applied "20251123204000_fix_cascade_delete"
|
||||||
|
npx prisma migrate resolve --applied "20251124182259_add_exclude_from_global"
|
||||||
|
npx prisma migrate resolve --applied "20251124231438_add_genre_active_field"
|
||||||
|
npx prisma migrate resolve --applied "20251125101602_add_news_model"
|
||||||
|
npx prisma migrate resolve --applied "20251128131405_add_i18n_columns"
|
||||||
|
npx prisma migrate resolve --applied "20251128132806_switch_to_json_columns"
|
||||||
|
|
||||||
echo "✅ Baseline complete! Restart the container to apply migrations normally."
|
echo "✅ Baseline complete! Restart the container to apply migrations normally."
|
||||||
|
|||||||
@@ -9,11 +9,23 @@ fi
|
|||||||
|
|
||||||
echo "Starting deployment..."
|
echo "Starting deployment..."
|
||||||
|
|
||||||
# Run migrations
|
# Run migrations with fallback to baseline if needed
|
||||||
echo "Running database migrations..."
|
echo "Running database migrations..."
|
||||||
npx prisma migrate deploy
|
if ! npx prisma migrate deploy; then
|
||||||
|
echo "⚠️ Migration failed, attempting to baseline existing database..."
|
||||||
|
if [ -f /app/scripts/baseline-migrations.sh ]; then
|
||||||
|
sh /app/scripts/baseline-migrations.sh
|
||||||
|
echo "Retrying migrations after baseline..."
|
||||||
|
npx prisma migrate deploy || {
|
||||||
|
echo "❌ Migration failed even after baseline. Please check your database."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
echo "❌ ERROR: Migration failed and baseline script not found at /app/scripts/baseline-migrations.sh"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "✅ Migrations completed successfully"
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
echo "Starting application..."
|
echo "Starting application..."
|
||||||
|
|||||||
Reference in New Issue
Block a user