All blocks

Platform

JSON Schema checks for jsonb

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

DocsModes:managed
terminal
npx better-supabase sql add jsonb-schemas
better-supabase.config.ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  sql: {
    modules: {
      // Modes: "managed". The default is "managed".
      "jsonb-schemas": { mode: "managed" },
    },
  },
});