- Added SQLite database support with Alembic for migrations. - Implemented FastAPI for HTTP API to manage duties. - Updated configuration to include database URL and HTTP port. - Created entrypoint script for Docker to handle migrations and permissions. - Expanded command handlers to register users and display duties. - Developed a web application for calendar display of duties. - Included necessary Pydantic schemas and SQLAlchemy models for data handling. - Updated requirements.txt to include new dependencies for FastAPI and SQLAlchemy.
12 lines
544 B
Python
12 lines
544 B
Python
"""Database layer: SQLAlchemy models, Pydantic schemas, repository, init."""
|
|
from db.models import Base, User, Duty
|
|
from db.schemas import UserCreate, UserInDb, DutyCreate, DutyInDb, DutyWithUser
|
|
from db.session import get_engine, get_session_factory, get_session
|
|
from db.repository import get_or_create_user, get_duties, insert_duty
|
|
|
|
|
|
def init_db(database_url: str) -> None:
|
|
"""Create tables from metadata (Alembic migrations handle schema in production)."""
|
|
engine = get_engine(database_url)
|
|
Base.metadata.create_all(bind=engine)
|