init
This commit is contained in:
26
docker-entrypoint.sh
Normal file
26
docker-entrypoint.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "📦 Running Alembic migrations..."
|
||||
|
||||
export SKIP_SCHEMA_BOOTSTRAP=1
|
||||
|
||||
MISSING=$(python3 <<EOF
|
||||
from sqlalchemy import create_engine, inspect
|
||||
from backend.core.settings import SQLALCHEMY_DATABASE_URI
|
||||
|
||||
engine = create_engine(SQLALCHEMY_DATABASE_URI)
|
||||
inspector = inspect(engine)
|
||||
tables = inspector.get_table_names()
|
||||
print("1" if "users" not in tables else "0")
|
||||
EOF
|
||||
)
|
||||
|
||||
if [ "$MISSING" -eq "1" ]; then
|
||||
echo "'users' table missing. Running Alembic migrations..."
|
||||
alembic -c alembic.ini upgrade head
|
||||
else
|
||||
echo "DB already initialized. Skipping migrations."
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user