From 3e3763361934a7e383bdef3145eea0fa1b8e875b Mon Sep 17 00:00:00 2001 From: Nemo Date: Thu, 19 Mar 2026 07:51:12 +0800 Subject: [PATCH] fix: drop+recreate DB schema on startup to clear old v1 tables --- backend/start.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/start.sh b/backend/start.sh index b360b0f..e0d474d 100644 --- a/backend/start.sh +++ b/backend/start.sh @@ -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