Update database setup to include simple migrations and enhance .gitignore

- Added the `run_simple_migrations` function call in the database initialization process to ensure any missing columns are added during setup.
- Updated the .gitignore file to exclude the `models_old.py` file, improving project cleanliness.
This commit is contained in:
machka-pasla
2025-09-04 19:52:57 +03:00
parent f11ec6a676
commit 807e3dadd3
3 changed files with 70 additions and 0 deletions
+3
View File
@@ -4,6 +4,7 @@ from sqlalchemy.orm import sessionmaker
from config.settings import Settings
from .models import Base
from .migrator import run_simple_migrations
async_engine = None
@@ -62,6 +63,8 @@ async def init_db(settings: Settings, session_factory: sessionmaker):
async with async_engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
# Run lightweight, idempotent migrations to add any missing columns
await conn.run_sync(run_simple_migrations)
logging.info(
"PostgreSQL database initialized/checked successfully using SQLAlchemy."
)