quartermaster/alembic
archeious 517578f4f3 feat(db): add Posting model, derive MonthEntry.applied, seed opening balances
Posting is a child of MonthEntry with occurred_on, amount, optional
description and payee. Cascade delete so removing an entry wipes its
ledger. Ordered on load by occurred_on DESC for readable UIs.

MonthEntry.applied becomes a @property summing posting amounts. The
stored applied column is dropped in the same migration.

The migration walks existing month_entry rows: for every non-zero
applied value, it inserts one opening-balance posting on the month's
activated_at (or created_at) date with description "opening balance"
and amount equal to the existing applied. Empty applied values get
no opening posting. Closed months go through the same path; their
totals stay intact via that single seeded row.

Downgrade is symmetric: re-adds the column and populates from
SUM(postings).

Refs #19

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 17:34:34 -06:00
..
versions feat(db): add Posting model, derive MonthEntry.applied, seed opening balances 2026-04-17 17:34:34 -06:00
env.py feat(ops): alembic env hook invokes backup-db.sh before migrations 2026-04-17 11:51:49 -06:00
README feat(db): add Entry and DebtTarget models with initial migration 2026-04-17 11:04:06 -06:00
script.py.mako feat(db): add Entry and DebtTarget models with initial migration 2026-04-17 11:04:06 -06:00

Generic single-database configuration.