Skip to content

feat: experimental db pull as declarative schemas - #4722

Merged
sweatybridge merged 18 commits into
developfrom
format-dump
Jan 30, 2026
Merged

feat: experimental db pull as declarative schemas#4722
sweatybridge merged 18 commits into
developfrom
format-dump

Conversation

@sweatybridge

@sweatybridgesweatybridge commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

feature

What is the new behavior?

supabase db pull --experimental

Cluster-Wide Objects (cluster/)

FilePostgreSQL Objects
roles.sqlCREATE ROLE, ALTER ROLE, GRANT role TO role
extensions.sqlCREATE EXTENSION
foreign_data_wrappers.sqlCREATE FOREIGN DATA WRAPPER, CREATE SERVER, CREATE USER MAPPING
publications.sqlCREATE PUBLICATION, ALTER PUBLICATION
subscriptions.sqlCREATE SUBSCRIPTION, ALTER SUBSCRIPTION
event_triggers.sqlCREATE EVENT TRIGGER, ALTER EVENT TRIGGER
tablespaces.sqlCREATE TABLESPACE, ALTER TABLESPACE
variables.sqlSET check_function_bodies = false;, ALTER SYSTEM, CREATE DATABASE

Schema-Scoped Objects (inside schemas/{schema}/)

DirectoryFile(s)PostgreSQL Objects
schemas/{schema}/schema.sqlCREATE SCHEMA, CREATE COLLATION, CREATE OPERATOR FAMILY, CREATE TEXT SEARCH, schema-level GRANT, schema-level ALTER DEFAULT PRIVILEGE
schemas/{schema}/types.sqlCREATE TYPE (enum, composite, range)
schemas/{schema}/sequences.sqlCREATE SEQUENCE, ALTER SEQUENCE (excluding owned by)
schemas/{schema}/tables/{table}.sqlCREATE TABLE, ALTER TABLE (excluding foreign key constraints), CREATE INDEX, CREATE POLICY, BEFORE/AFTER CREATE TRIGGER, trigger functions, table GRANT, COMMENT
schemas/{schema}/views/{view}.sqlCREATE VIEW, INSTEAD OF CREATE TRIGGER, view GRANT, COMMENT
schemas/{schema}/materialized_views/{mview}.sqlCREATE MATERIALIZED VIEW, indexes, GRANT, COMMENT
schemas/{schema}/functions/{function}.sqlCREATE FUNCTION (including all overloads and trigger functions), GRANT, COMMENT
schemas/{schema}/procedures/{procedure}.sqlCREATE PROCEDURE, GRANT, COMMENT
schemas/{schema}/foreign_tables/{ftable}.sqlCREATE FOREIGN TABLE, GRANT
schemas/{schema}/domains/{domain}.sqlCREATE DOMAIN, ALTER DOMAIN
schemas/{schema}/operators/{operator}.sqlCREATE OPERATOR, ALTER OPERATOR, CREATE OPERATOR CLASS, CREATE AGGREGATE, CREATE TRANSFORM
schemas/{schema}/policies/{policy}.sqlCREATE POLICY, CREATE RULE, foreign key constraints
schemas/unqualified.sqlSELECT lo_create(), CREATE CAST

Additional context

Known caveats

  1. Tables may depend on functions using check constraint
CREATETABLEIF NOT EXISTS "public"."employees" (
"name""text",
CONSTRAINT"name_check"CHECK ("public"."is_valid_name"("name"))
);
  1. Function may depend on tables from return type
CREATE OR REPLACEFUNCTION "public"."create_employee"("name""text") RETURNS "public"."employees"
LANGUAGE "plpgsql"SET"search_path" TO ''AS $$
DECLARE
result_row public.employees%ROWTYPE;
BEGININSERT INTOpublic.employees (name) VALUES (name) RETURNING * INTO result_row;
RETURN result_row;
END;
$$;
  1. Sequences may be referenced by create or alter tables statement
  2. Views may have forward declarations

@sweatybridge
sweatybridge requested a review from a team as a code ownerJanuary 15, 2026 10:26
@coveralls

coveralls commented Jan 17, 2026

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 21473922934

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 259 of 599(43.24%) changed or added relevant lines in 2 files are covered.
  • 38 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.6%) to 55.543%

Changes Missing CoverageCovered LinesChanged/Added Lines%
internal/db/pull/pull.go1911.11%
internal/migration/format/format.go25859043.73%
Files with Coverage ReductionNew Missed Lines%
internal/storage/rm/rm.go280.61%
internal/gen/keys/keys.go512.9%
internal/start/start.go3165.85%
TotalsCoverage Status
Change from base Build 20983346857:-0.6%
Covered Lines:7109
Relevant Lines:12799

💛 - Coveralls

@sweatybridgesweatybridge changed the title feat: squash migrations to declarative schemasfeat: experimental db pull as declarative schemasJan 17, 2026
@sweatybridge
sweatybridge merged commit 623610a into developJan 30, 2026
11 of 12 checks passed
@sweatybridge
sweatybridge deleted the format-dump branch January 30, 2026 06:47
@supabase-cli-releasersupabase-cli-releaserBot mentioned this pull request Feb 3, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@sweatybridge@coveralls