add auto migrations
This commit is contained in:
parent
e263fbc98a
commit
b29823a6b1
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue