fix: drop+recreate DB schema on startup to clear old v1 tables
This commit is contained in:
@@ -4,11 +4,22 @@ set -e
|
||||
echo "Waiting for database..."
|
||||
sleep 3
|
||||
|
||||
echo "Running migrations..."
|
||||
python -c "from app.database import engine; from app.models import Base; Base.metadata.create_all(bind=engine)"
|
||||
echo "Resetting database schema..."
|
||||
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..."
|
||||
python /app/seed.py || echo "Seed already exists or failed (non-fatal)"
|
||||
python /app/seed.py
|
||||
|
||||
echo "Starting server..."
|
||||
exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 1
|
||||
|
||||
Reference in New Issue
Block a user