Files
duty-teller/duty_teller/db/__init__.py
Nikolay Tatarinov 86f6d66865
All checks were successful
CI / lint-and-test (push) Successful in 17s
chore: add changelog and documentation updates
- Created a new `CHANGELOG.md` file to document all notable changes to the project, adhering to the Keep a Changelog format.
- Updated `CONTRIBUTING.md` to include instructions for building and previewing documentation using MkDocs.
- Added `mkdocs.yml` configuration for documentation generation, including navigation structure and theme settings.
- Enhanced various documentation files, including API reference, architecture overview, configuration reference, and runbook, to provide comprehensive guidance for users and developers.
- Included new sections in the README for changelog and documentation links, improving accessibility to project information.
2026-02-20 15:32:10 +03:00

61 lines
1.3 KiB
Python

"""Database layer: SQLAlchemy models, Pydantic schemas, repository, init."""
from duty_teller.db.models import Base, User, Duty
from duty_teller.db.schemas import (
UserCreate,
UserInDb,
DutyCreate,
DutyInDb,
DutyWithUser,
)
from duty_teller.db.session import (
get_engine,
get_session_factory,
get_session,
session_scope,
)
from duty_teller.db.repository import (
delete_duties_in_range,
get_or_create_user,
get_or_create_user_by_full_name,
get_duties,
insert_duty,
set_user_phone,
update_user_display_name,
)
__all__ = [
"Base",
"User",
"Duty",
"UserCreate",
"UserInDb",
"DutyCreate",
"DutyInDb",
"DutyWithUser",
"get_engine",
"get_session_factory",
"get_session",
"session_scope",
"delete_duties_in_range",
"get_or_create_user",
"get_or_create_user_by_full_name",
"get_duties",
"insert_duty",
"set_user_phone",
"update_user_display_name",
"init_db",
]
def init_db(database_url: str) -> None:
"""Create all tables from SQLAlchemy metadata.
Prefer Alembic migrations for schema changes in production.
Args:
database_url: SQLAlchemy database URL.
"""
engine = get_engine(database_url)
Base.metadata.create_all(bind=engine)