The Rules section is one record table grouped by kind, Limit then Boolean, on fixed columns, edited in place: Edit opens a row's controls in their columns, Add rule opens a dense row above the table, and every change is staged into a tray that lists the deltas with Undo and applies them as one rule-change act. The reduction policy is a column of the rule beside its limit. History shows counts only. Group rows are a quiet heading rather than a divider, the maintainer's pick from four rounds of outside-model ideation. Dense rows align to the top and render each error under its control in every form family (design D16), replacing the below-row error block; the forms library gains the batch form (rows plus one tray) and the RowField dense and label-hidden options. Migration 00019 records the governing reduction policy on effect rows. Archive staged-rule-changes with its spec updates (entitlement-set- management, entitlement-set-history, entitlements, form-library, form-conventions, ui-quality-gate). Screens accepted 2026-09-19.
56 lines
2.0 KiB
SQL
56 lines
2.0 KiB
SQL
-- name: GetEntitlementSetByID :one
|
|
SELECT * FROM core.entitlement_sets
|
|
WHERE set_id = $1;
|
|
|
|
-- name: ListEntitlementSets :many
|
|
SELECT * FROM core.entitlement_sets
|
|
ORDER BY name ASC;
|
|
|
|
-- name: ListActiveEntitlementSets :many
|
|
SELECT * FROM core.entitlement_sets
|
|
WHERE is_active = TRUE
|
|
ORDER BY name ASC;
|
|
|
|
-- name: CreateEntitlementSet :one
|
|
-- `key` is the optional declarative address (entity-keys §3), root-scoped.
|
|
-- The operator create form does not collect one, so a UI-created set leaves
|
|
-- it NULL; a seed or a configuration loader supplies it.
|
|
INSERT INTO core.entitlement_sets (name, description, is_active, key)
|
|
VALUES ($1, $2, $3, sqlc.narg(key))
|
|
RETURNING *;
|
|
|
|
-- name: GetEntitlementSetByKey :one
|
|
-- Root key resolver (entity-keys §5). uq_entitlement_sets_key guarantees at
|
|
-- most one row matches.
|
|
SELECT * FROM core.entitlement_sets
|
|
WHERE key = $1;
|
|
|
|
-- name: UpdateEntitlementSet :one
|
|
UPDATE core.entitlement_sets
|
|
SET name = $2, description = $3, is_active = $4
|
|
WHERE set_id = $1
|
|
RETURNING *;
|
|
|
|
-- name: AnyActiveEntitlementSet :one
|
|
-- Setup-checklist existence probe: the whole-table answer, not a lookup.
|
|
SELECT EXISTS(SELECT 1 FROM core.entitlement_sets WHERE is_active = TRUE);
|
|
|
|
-- name: ListEntitlementSetsByIDs :many
|
|
-- The products list's set names for one page in one read (purchasability-
|
|
-- status "The verdict per page, from batches, never cached", design D4,
|
|
-- folded in on the maintainer's word 2026-09-06): the sets the page's
|
|
-- products reference, instead of GetEntitlementSetByID once per row.
|
|
SELECT * FROM core.entitlement_sets
|
|
WHERE set_id = ANY(sqlc.arg(set_ids)::uuid[])
|
|
ORDER BY name ASC;
|
|
|
|
-- name: LockEntitlementSet :one
|
|
-- The set row taken FOR UPDATE: the guard a rule change holds beside the
|
|
-- exclusive materialization rendezvous against a writer that changes the set
|
|
-- row without that lock. A batch takes it once for every act it files
|
|
-- (entitlement-set-management, "A rule change commit reaches every carrying
|
|
-- pool").
|
|
SELECT set_id FROM core.entitlement_sets
|
|
WHERE set_id = $1
|
|
FOR UPDATE;
|