fix: prevent set -e from killing entrypoint on DB detection
The python3 DB detection script exits with code 1 (empty) or 2 (legacy), but entrypoint has set -e which kills the script on any non-zero exit. Fixed by using '|| _db_state=$?' pattern to safely capture exit code without triggering set -e.
This commit is contained in:
@@ -152,18 +152,19 @@ install_certificates
|
||||
install_playwright
|
||||
|
||||
# Check DB state: empty, legacy (tables exist but no alembic), or managed
|
||||
# || prevents set -e from killing the script on non-zero exit from detection script
|
||||
_db_state=0
|
||||
python3 -c "
|
||||
import os
|
||||
from sqlalchemy import create_engine, inspect
|
||||
e = create_engine(os.environ['DATABASE_URL'])
|
||||
insp = inspect(e)
|
||||
if 'alembic_version' in insp.get_table_names():
|
||||
exit(0) # managed → normal upgrade
|
||||
exit(0)
|
||||
if not insp.get_table_names():
|
||||
exit(1) # empty → fresh upgrade
|
||||
exit(2) # legacy → stamp head
|
||||
" 2>/dev/null
|
||||
_db_state=$?
|
||||
exit(1)
|
||||
exit(2)
|
||||
" 2>&1 || _db_state=$?
|
||||
|
||||
if [ $_db_state -eq 0 ]; then
|
||||
echo "[entrypoint] Running Alembic migrations (incremental)..."
|
||||
|
||||
Reference in New Issue
Block a user