add auto migrations

This commit is contained in:
itqop 2025-12-31 01:52:47 +03:00
parent e263fbc98a
commit b29823a6b1
2 changed files with 7 additions and 4 deletions

View File

@ -51,6 +51,11 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
async def init_db() -> None:
"""Initialize database tables."""
"""
Initialize database tables using create_all().
WARNING: Only for testing! In production/dev, use Alembic migrations.
Using both create_all() and Alembic creates inconsistent state.
"""
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)

View File

@ -7,7 +7,6 @@ from fastapi.middleware.cors import CORSMiddleware
from app.api.v1 import assets, auth, batch, folders, shares, uploads
from app.infra.config import get_settings
from app.infra.database import init_db
settings = get_settings()
@ -15,8 +14,7 @@ settings = get_settings()
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Application lifespan handler."""
# Startup
await init_db()
# Startup - schema managed by Alembic migrations in Dockerfile
yield
# Shutdown
pass