Plugin tables — re_*
The register plugin owns its schema end to end: it migrates itself inside
sqlite.NewDB, before the host's own baseline runs, and no statement in
the host's SQL writes a register row. This page records what exists and who
owns it; the authoritative definition lives in the plugin's migrations, and the
money rules live in nx-register.
| Table | Owner | Role |
|---|---|---|
re_boxes |
nx-register | a drawer: identity is the (currency, method) pair; currency and method freeze once the box has lines; balance is derived from lines, never stored |
re_movements |
nx-register | one document-level posting: date, type (receipt/expense/salary/adjustment/transfer), currency, method, reference pair (ref_type/ref_id), status (posted/voided), meta |
re_lines |
nx-register | the money itself: amount_minor (integer), side, the box it lands in; a movement carries exactly one line, and a void appends a reversing line rather than deleting |
re_closes |
nx-register | one period close: the locked-through date and its timestamps |
re_counts |
nx-register | one drawer count inside a close: expected vs counted, with variance |
re_settings |
nx-register | key/value rows for the plugin's own settings (lock_enforced, varariance_category), behind the settings contract |
re_migrations |
nx-register | the plugin's own migration ledger |
bun_migrations, bun_migration_locks |
nx-register (bun) | the ORM's migration bookkeeping for the plugin's migrator |
The invariant every query respects
SUM(re_lines) == SUM(re_movements WHERE status = 'posted')
A void flips the movement's status and appends a reversal line, so the sum over posted movements stays equal to the sum over all lines, and the naive "sum every movement" overstates by exactly the voided amount. This was verified on the deployed tenant after a salary cancellation: the box balance matched the posted-only sum exactly.
What the host may not do
- no host migration may create, alter or drop an
re_*orbun_*table; - no host query may read or write one directly — the money service reaches them
only through the plugin's typed
Servicebehindmoney.RegisterHost; ref_type = 'transfer'is reserved for the plugin's own transfer pair, and the host'spayment_lines.movement_idis a plain string link with no cross-owner foreign key.
Not determined
- Exact column lists and types for the
re_*tables were not read from the plugin's migrations for this pass (nx-register is a separate private module); the table purposes above are what the host's binding and the acceptance run establish.
Rendered from simple-lms/data-model/plugin-tables.md · OKF bundle · regenerate with npm run render