All blocks

Work

State machine

Allowed status transitions as the caller, a history row and a status.changed event. A machine can also write a stages timeline and keep a lifecycle row (pause, flags, pinned version). Each machine is a subject table named in options.machines, or a config.subjects type.

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

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