type
Data Model
title
Plugin tables (nx-register)
description
The re_* ledger the register plugin owns and migrates itself — documented here, defined in the plugin, never touched by host SQL.
tags
plugin, register, ledger, re-tables
status
stable
stale_after
Fri Apr 30 2027 02:00:00 GMT+0200 (Central European Summer Time)
generated
techwriter/mimo-v2.6-flash · Sat Oct 31 2026 11:02:38 GMT+0100 (Central European Standard Time)
sources
plugin → https://github.com/nextrum-sy/nx-register; bundle → /plugins/re/register-plugin.md; schema → internal/infrastructure/sqlite/migrations/001_schema.sql; host → internal/infrastructure/sqlite/register_host.go

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

Not determined

Rendered from simple-lms/data-model/plugin-tables.md · OKF bundle · regenerate with npm run render