fix: automatic DB migration — run before backend starts
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 3s

Three fixes to ensure alembic migrations always run in production:

1. entrypoint.sh: add `exec "$@"` passthrough so `docker compose run
   --rm backend alembic upgrade head` actually runs alembic instead of
   ignoring args and starting uvicorn.

2. entrypoint.sh: remove `|| echo` fallback on alembic — if migration
   fails the container must stop, not silently continue.

3. deploy.yml: start only postgres+redis first, run migration, THEN
   start backend. Previously the backend started before migration,
   ran with stale schema, and the separate migration step was broken
   by the entrypoint bug.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-17 11:03:42 +02:00
parent 413f610f1a
commit 6c0ecded47
2 changed files with 34 additions and 26 deletions

View File

@@ -1,6 +1,12 @@
#!/bin/bash
set -e
# If a command is passed (e.g. `docker compose run --rm backend alembic upgrade head`),
# run it directly instead of the full startup sequence.
if [ $# -gt 0 ]; then
exec "$@"
fi
echo "🚀 Starting Document Translation API..."
# Wait for database to be ready (if DATABASE_URL is set)
@@ -42,7 +48,7 @@ except:
# Run database migrations
echo "📦 Running database migrations..."
alembic upgrade head || echo "⚠️ Migration skipped (may already be up to date)"
alembic upgrade head
fi
# Wait for Redis if configured