fix: automatic DB migration — run before backend starts
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 3s
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user