Overview
What it provides (orchestration/include/db)
Section titled “What it provides (orchestration/include/db)”models/— SQLModel table definitions:Company,CompanyPermit,CompanyUser,DashboardUser,Permit,ReportPeriod,Purchase,Sale,Inventory,Import,Export,ReportJob/JobStatus. (Importis loaded viaimportlibsinceimportis a reserved keyword.)alembic/— migration environment (env.py,versions/) andalembic.ini, run via thedb_migrations/db_rollbackAirflow DAGs. See Orchestration → Database & Migrations for the migration workflow.persist.py— bulk-insert helpers for writing cleaned Polars DataFrames to PostgreSQL from Airflow tasks, e.g.:from airflow.providers.postgres.hooks.postgres import PostgresHookfrom db.persist import persist_reporthook = PostgresHook(postgres_conn_id="my-pg")engine = create_engine(hook.get_uri())persist_report(engine=engine, ...)migrate.py— migration entry point used by the Airflow DAGs.
Dependencies: alembic, psycopg[binary], sqlmodel, uuid-utils. Built with uv_build, not hatchling.
Connection & identity
Section titled “Connection & identity”Connections use PostgresHook/SQLAlchemy engines configured via Airflow connections, ultimately backed by the same Azure AD-token authentication model described in Architecture → Identity & Security (developer identity locally via AZURE_USERNAME/AZURE_PG_TOKEN, service identity in production).
The packages/db scaffold
Section titled “The packages/db scaffold”packages/db (root workspace, packages/db/pyproject.toml, depends on utils) contains conn.py (commented-out SQLAlchemy URL builder), auth.py (commented-out Key Vault-backed credential fetcher), and PostgresDBHelper.py (commented-out psycopg context-manager helper) — all disabled. If this package is revived for use outside orchestration/, update this page accordingly; until then, treat orchestration/include/db as the source of truth for database access patterns.