quartermaster/alembic/versions
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
..
03ebe3c07262_add_month_snapshot_tables.py feat(db): add Month, MonthEntry, and MonthDebtTarget models with migration 2026-04-17 11:57:30 -06:00
a4ec4f8f6e9f_add_month_lifecycle_state.py feat(db): add MonthState enum and lifecycle columns 2026-04-17 13:03:53 -06:00
cc60e7f73a1c_add_posting_ledger_drop_month_entry_.py feat(db): add Posting model, derive MonthEntry.applied, seed opening balances 2026-04-17 17:34:34 -06:00
ec804bdf366d_add_notes_column_to_entry_and_month_.py feat(db): add nullable notes column to entry and month_entry 2026-04-17 12:51:22 -06:00
f1ccdc4bc1bf_initial_schema.py feat(db): add Entry and DebtTarget models with initial migration 2026-04-17 11:04:06 -06:00