Skip to content

fix(pg-delta): supabase add support for pgmq extension#191

Merged
avallete merged 6 commits intomainfrom
fix/add-support-for-pgmq-extension
Apr 15, 2026
Merged

fix(pg-delta): supabase add support for pgmq extension#191
avallete merged 6 commits intomainfrom
fix/add-support-for-pgmq-extension

Conversation

@avallete
Copy link
Copy Markdown
Member

Summary

Fixes declarative schema apply failing for projects using the pgmq extension when the Supabase integration exports extension DDL that includes WITH SCHEMA pgmq, while CREATE SCHEMA pgmq is not part of the exported set (system schema filtering). Also formalizes SerializeOptions so integration serialize rules and Change.serialize() share one typed contract, documents those types in TypeDoc, and adds a regression test for the export → apply pipeline.

Problem

PostgreSQL requires the target schema to already exist before CREATE EXTENSION … WITH SCHEMA <schema>. On a fresh database (e.g. shadow DB / clean apply), the pgmq schema typically does not exist yet. The pgmq extension creates that schema as part of installation, but the server validates WITH SCHEMA before running the extension scripts—so CREATE EXTENSION pgmq WITH SCHEMA pgmq fails with schema "pgmq" does not exist unless something else has pre-created pgmq.
Separately, wiring serialize options through the integration DSL exposed a typing gap: the Change union did not consistently accept serialize(options) until concrete change types aligned on a shared options type.

Solution

  • Supabase integration: Serialize rule for pgmq extension creates so emitted SQL omits WITH SCHEMA (plain CREATE EXTENSION pgmq;), avoiding the invalid ordering on a fresh database when the schema create is not exported.
  • Core typing: Central SerializeOptions in serialize.types.ts, used by compileSerializeDSL, BaseChange.serialize, and concrete serializers; CreateExtension honors skipSchema where applicable.
  • Docs: Re-export serializer option types from the TypeDoc entrypoint and add TSDoc so they appear in the generated API reference.
  • Tests: Integration regression covering declarative export + apply roundtrip for a Supabase-shaped pgmq setup; unit coverage for DSL / extension serialization behavior.
  • Changeset: Patch bump for @supabase/pg-delta.

avallete and others added 5 commits April 14, 2026 13:11
… output (#154)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: avallete <8771783+avallete@users.noreply.github.com>
Co-authored-by: Andrew Valleteau <avallete@users.noreply.github.com>
Co-authored-by: avallete <andrew.valleteau@supabase.io>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 14, 2026

🦋 Changeset detected

Latest commit: 7bdaf92

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@supabase/pg-delta Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Member Author

@avallete avallete left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the changes are about adding a _options: SerializeOptions into every serialize change implementation, so downstream dsl filter can have some typing correctly infered.

Real changes are in:

packages/pg-delta/src/core/integrations/supabase.ts
packages/pg-delta/tests/integration/pgmq-declarative-roundtrip.test.ts

@avallete avallete requested a review from jgoux April 14, 2026 14:59
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 14, 2026

Open in StackBlitz

npm i https://pkg.pr.new/supabase/pg-toolbelt/@supabase/pg-delta@191
npm i https://pkg.pr.new/supabase/pg-toolbelt/@supabase/pg-topo@191

commit: 7bdaf92

@avallete avallete added this pull request to the merge queue Apr 15, 2026
Merged via the queue into main with commit e065101 Apr 15, 2026
58 checks passed
@avallete avallete deleted the fix/add-support-for-pgmq-extension branch April 15, 2026 08:07
Sign up for free to 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.

3 participants