Replies: 1 comment
|
This is a big one for the October 30 change specifically — grants and policies becoming first-class generated objects means the exact thing people are scrambling to audit manually (which grants exist, which policies scope them) is now declarative and diffable. Two questions on scope: 1. Does pg-delta diff 2. How does the grants diff treat the platform-managed grants on Also: the "review it" step in the workflow is doing a lot of quiet load-bearing work, and it's the step people skip. The failure mode we keep seeing in the wild is a generated migration that's correct but unread — someone reviews the first 20 lines of a 200-line grants diff and ships it. If the CLI could emit a summary header in the generated file ("+12 grants, -3 policies, 2 tables, 0 default-privilege changes"), review quality would go up the same way test summaries did. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
At Supabase Select on October 2 we shipped Declarative Schemas 2.0. The Supabase CLI now generates migrations with
pg-delta, a Postgres diff engine we wrote and open sourced, in place ofmigra. Generated migrations now include RLS policy changes, grants, view settings, partitions, domains, and objects that extensions manage.The workflow is the same: edit a file, generate the migration, review it, and apply it. New CLI projects get 2.0 by default. Existing projects opt in with one config block.
pg-deltais in alpha, so breaking changes can land between releases.What changed
Declarative schemas first launched in April 2025. You keep your schema in
.sqlfiles undersupabase/schemas/and the CLI writes the migration. The diff engine behind it,migra, left out some object kinds, so you had to check each generated migration for what was missing.pg-deltareplaces it. The CLI starts two throwaway Postgres databases, loads your schema files into one, and replays your migration history into the other.pg-deltathen compares the two by reading the system catalog. It never reads your live database.What's included
security_invokeron views, materialized views, column privileges, comments, partitions, publications, and domainspg_partmanpartitions andpgmqqueue tables never come out as rawcreate tableordrop table, and the CLI flags drops as destructive. A newpg_cronjob comes out ascron.schedule_in_database, a removed job ascron.unschedule, and a changed job as both--strict-coveragefails CI on themschema_pathssupabase db schema declarative generate --linkedwrites schema files from an existing databasepg-deltaalso runs on its own against any Postgres 14 through 18, with no Supabase accountWhat it doesn't do yet
pg-deltagenerates schema changes, not data changes, and it doesn't diff Storage buckets. It also doesn't orchestrate zero-downtime rollouts. A renamed column comes out as a drop and an add, so review anything the CLI flags as destructive before you apply it.Getting started
pg-deltafromsupabase init. For an existing project, add[experimental.pgdelta]withenabled = truetosupabase/config.toml, then runsupabase db schema declarative syncto write the migration. Projects without it keep runningmigrasupabase db pullsupabase db pullfirst so your migration history records it. Otherwise the next sync generates it again, anddb pushfails because the object already existsFeedback welcome
Reply here with anything that looks wrong in a generated migration.
Earlier feedback from the public alpha is in discussion 44938: https://github.com/orgs/supabase/discussions/44938
All reactions