Number sequences
numberingGapless numbers per tenant, entity and period. next_number locks the row in the caller's transaction, and a trigger fills the document column so a separate round trip cannot open a gap.
Database primitivesmanagedadoptcustom
Install
The command also installs updated-at, memberships, permissions, the modules it needs.
npx better-supabase add numberingConfigure
The blocks entries in your config, with the default mode.
import { defineConfig } from "better-supabase/config";
export default defineConfig({
blocks: {
// Required by numbering; add installs them too.
"updated-at": {},
memberships: {},
permissions: {},
// Modes: "managed", "adopt", "custom". The default is "managed".
numbering: { mode: "managed" },
},
});Migrations
The files
npx better-supabase add numbering writes into your declarative schema with the default layout.Client
This block has no React entry yet. Its TypeScript side is in better-supabase/blocks/numbering, which runs on the server.
Events
With the outbox installed, the module writes these in the same transaction as the change.
- number.assigned
Dependencies
Recipes
No UI recipe uses it yet. See all recipes.
More in Database primitives
- Update timestampsupdated-atKeeps an updated_at column current on every update.
- Realtime table changesrealtime-tablesBroadcasts a change signal (no row data) once per statement on bsb:t:<schema>.<table>[:<tenant>], or bsb:t:<schema>.<table>:u:<user> for realtime.users tables, for live queries.
- JSON Schema checks for jsonbjsonb-schemaspg_jsonschema check constraints for jsonb columns with a `schema` in the `json` config, so the database enforces the same shape as the types. A trigger reports what failed through jsonschema_validation_errors, which the client maps to a validation error.
- pgTAP helperspgtaptests.create_user, tests.authenticate_as and catalog checks (every_table_has_rls, policies_use, no_anon_policies, every_table_audited, partitions_have_rls) for `supabase test db`. Written to supabase/tests, never to your schema.
- Read setsread-setsOne `stable` function per `defineReadSet` in `readSets`, so `db.$many(readSet, params)` is a single GET.
- RankrankFractional rank keys: rank_between, move() for every config.records entry with a rank column (through the caller's policies and any state-machine trigger), and a rebalance job.