fix: drop+recreate DB schema on startup to clear old v1 tables

This commit is contained in:
Nemo
2026-03-19 07:51:12 +08:00
parent 4421f61c24
commit 3e37633619

View File

@@ -4,11 +4,22 @@ set -e
echo "Waiting for database..." echo "Waiting for database..."
sleep 3 sleep 3
echo "Running migrations..." echo "Resetting database schema..."
python -c "from app.database import engine; from app.models import Base; Base.metadata.create_all(bind=engine)" python -c "
from app.database import engine
from app.models import Base
import sqlalchemy as sa
# Drop all tables for clean v2 schema
print('Dropping old tables...')
Base.metadata.drop_all(bind=engine)
print('Creating new tables...')
Base.metadata.create_all(bind=engine)
print('Schema ready.')
"
echo "Seeding data..." echo "Seeding data..."
python /app/seed.py || echo "Seed already exists or failed (non-fatal)" python /app/seed.py
echo "Starting server..." echo "Starting server..."
exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 1 exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 1