All blocks

Platform

Number sequences

Gapless 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.

DocsModes:managedadoptcustom
terminal
npx better-supabase sql add number-sequences
better-supabase.config.ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  sql: {
    modules: {
      // Required by number-sequences; sql add installs them too.
      "updated-at": {},
      tenant: {},
      access: {},
      // Modes: "managed", "adopt", "custom". The default is "managed".
      "number-sequences": { mode: "managed" },
    },
  },
});