---
title: "Declarative Schemas 2.0 with pg-delta"
description: "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."
url: "https://swe.quest/articles/declarative-schemas-2-0-with-pg-delta-0896bf8f6c8dbe4f"
canonical: "https://supabase.com/blog/declarative-schemas-2-0-pg-delta"
source: "Supabase"
published: "2026-10-13"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 11
tags: ["schema-migrations","postgres","developer-tools","open-source"]
---

# Declarative Schemas 2.0 with pg-delta

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2026-10-13, 11 min read, Announcement. Original: [https://supabase.com/blog/declarative-schemas-2-0-pg-delta](https://supabase.com/blog/declarative-schemas-2-0-pg-delta)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Schema migrations](https://swe.quest/tags/schema-migrations.md) (Data & databases)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)
- [Open source](https://swe.quest/tags/open-source.md) (Engineering practices)

## Prerequisites

- PostgreSQL schema objects ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- database migrations ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))
- Row Level Security ([easy posts on Security](https://swe.quest/tags/security.md?difficulty=easy))

## Keywords

pg-delta, Supabase CLI, migra, Declarative Schemas, pgmq, pg\_cron, Row Level Security

## Related posts

- [Declarative Schemas for Simpler Database Management](https://swe.quest/articles/declarative-schemas-for-simpler-database-management-ee2428d0ae8c51e8.md): Supabase · 2025-04-03 · Medium · 4 min read · Schema migrations, PostgreSQL, Developer tools
  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 CLI](https://swe.quest/articles/supabase-cli-a62c53c7dbec808f.md): Supabase · 2021-03-31 · Medium · 7 min read · Schema migrations, PostgreSQL, Developer tools
  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.
- [Supabase Local Dev: migrations, branching, and observability](https://swe.quest/articles/supabase-local-dev-migrations-branching-and-observability-770def662fe57683.md): Supabase · 2023-08-08 · Easy · 6 min read · PostgreSQL, Developer tools, Schema migrations, Testing, Deployment
  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.
- [The Vibe Coder's Guide to Supabase Environments](https://swe.quest/articles/the-vibe-coder-s-guide-to-supabase-environments-2ce71129a08af138.md): Supabase · 2025-08-17 · Medium · 10 min read · Schema migrations, CI/CD, Deployment, PostgreSQL, Identity & auth
  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.
- [What's new in Postgres 15?](https://swe.quest/articles/what-s-new-in-postgres-15-a6b4172551a1b66b.md): Supabase · 2022-12-16 · Easy · 3 min read · PostgreSQL, Replication, SQL
  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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
