feat(db): migrate to PostgreSQL 16 standalone
- docker-compose.prod.yml: add postgres:16-alpine service with health check, dedicated prod_leopost_net, backup volume mount, connection pool - requirements.txt: add psycopg2-binary==2.9.9 - database.py: remove SQLite-specific run_migrations(), add PG pool_size/ max_overflow/pool_pre_ping, keep sqlite compat for dev - main.py: remove run_migrations call, rely on create_all for PG - scripts/migrate_sqlite_to_pg.py: one-shot data migration script Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@ from fastapi.staticfiles import StaticFiles
|
||||
|
||||
from .auth import hash_password
|
||||
from .config import settings
|
||||
from .database import Base, SessionLocal, engine, run_migrations
|
||||
from .database import Base, SessionLocal, engine
|
||||
from .models import User
|
||||
from .routers.admin import router as admin_router
|
||||
from .routers.auth import router as auth_router
|
||||
@@ -79,10 +79,7 @@ async def lifespan(app: FastAPI):
|
||||
data_dir = Path("./data")
|
||||
data_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Run migrations FIRST (add new columns to existing tables)
|
||||
run_migrations(engine)
|
||||
|
||||
# Create tables (for new tables like subscription_codes)
|
||||
# Create all tables (PostgreSQL: idempotent, safe to run on every startup)
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
# Create or update admin user
|
||||
|
||||
Reference in New Issue
Block a user