Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Supabase 11 min read Announcement mediumAdept

Declarative Schemas 2.0 with pg-delta

Supabase replaced migra with pg-delta, its own open-source Postgres diff engine, as the generator behind declarative schema migrations in the Supabase CLI. pg-delta loads schema files and migration history into two shadow databases, diffs them by reading the system catalog, and orders output with a catalog-derived dependency graph. Generated migrations now cover RLS alter policy, grants, column privileges, view security_invoker, comments, roles, domains, publications, and extension-owned objects, which it changes through extension APIs such as pgmq and pg_cron. The engine favors coverage over minimal destructiveness: renames become drop-plus-add and need hand rewriting. It also skips data rows such as storage buckets, and a first parser-based design was scrapped because the SQL parser and catalog reader disagreed.

Related posts

  • Declarative Schemas for Simpler Database Management

    Supabase mediumAdept

    Supabase CLI now supports declarative schemas: the desired final state of Postgres tables, views, functions, RLS policies, grants and types lives in versioned .sql files, and a schema diff tool such as migra generates the migration files. Supabase used this internally for two years on its complex projects table, which sits in a private schema behind a public view with RLS-based ABAC and INSTEAD OF triggers. Previously, adding one column meant hand-copying view and trigger definitions into a migration of several hundred lines that conflicted often. Now it is a one-line diff, and generated migrations still get manual review. The team says this cut schema changes from hours to minutes and made rebasing much easier.

  • Supabase CLI

    Supabase mediumAdept

    Supabase's new CLI runs the full Supabase stack locally via Docker Compose, using the same tooling as production, and walks through wiring it to a React app. For migrations, Supabase prefers schema diffing over hand-written migration scripts. After evaluating migra, dbdiff, pgdiff, apgdiff, pgquarrel and pgAdmin Schema Diff, it picked pgAdmin's because it tracks VIEW owner changes, which Row Level Security on views depends on, and it also handles domains. Since pgAdmin's diff was GUI-only, Supabase built a CLI mode for it and shipped it as a Docker image. A `supabase eject` command emits docker-compose, Kong and Postgres configs for self-hosting.

  • Supabase Local Dev: migrations, branching, and observability

    Supabase easyNovice

    Supabase's CLI gains a batch of Postgres local-development features: `supabase inspect db` with 19 diagnostic commands adapted from Heroku's pg-extras, `db dump` backups built on pg_dump, migration squashing and diffing via migra, pgTAP testing with `supabase test`, plpgsql_check linting, seeding, and TypeScript type generation that now detects foreign-key relationships. Local logs are viewable in the dashboard, and the CLI moves to a fortnightly stable-release cycle with a beta channel. Branching enters alpha: each GitHub pull request gets an isolated Firecracker-based preview environment that runs the repo's migrations and seed.sql, with migrations applied to production on merge. Production data cloning is deliberately deferred until copy-on-write with anonymization is judged safe.

  • The Vibe Coder's Guide to Supabase Environments

    Supabase mediumAdept

    Separate Supabase projects for development and production, with all schema changes captured as timestamped SQL migrations in a Git-tracked supabase/ directory, keep a fast workflow from breaking live data. Changes flow one way: local → dev → prod. Every migration is proven with `supabase db reset`, and GitHub Actions runs `supabase db push` automatically on merges to develop and main. The guide also covers enabling Row Level Security on every table, keeping service role keys out of NEXT_PUBLIC_ variables, nightly backups plus Point in Time Recovery with monthly restore drills, and wiring Vercel preview and production environments to the matching database.

  • What's new in Postgres 15?

    Supabase easyNovice

    PostgreSQL 15 tightens the default permission model by revoking CREATE on the public schema from non-owners and adds security_invoker views that check the caller's permissions. Other headline changes include in-memory and on-disk sorts up to 4x faster, the SQL-standard MERGE command, and row/column filtering, two-phase commit and conflict-skipping options for logical replication. It also brings parallel SELECT DISTINCT, JSON logging, Zstandard/LZ4 compression for WAL and server-side base backups, and new regexp functions. The recommendation is to upgrade mainly for bug fixes and stability, using pg_upgrade and checking the release notes for cases that need manual action, such as revoking public-schema CREATE on migrated databases.

The quest for software engineering knowledge.

Look:
Layout: