Skip to content

fix(cli): keep event triggers in a schema-scoped declarative sync - #7914

Open
martijn00 wants to merge 1 commit into
supabase:developfrom
martijn00:fix/scoped-sync-event-triggers
Open

martijn00 wants to merge 1 commit into
supabase:developfrom
martijn00:fix/scoped-sync-event-triggers

Conversation

@martijn00

Copy link
Copy Markdown

Summary

db schema declarative sync -s <schemas> (and db diff -s) never planned event triggers, and printed nothing about it. The schema-scope policy in pgDeltaNextProfile excludes every change whose object is not in a selected schema, and an event trigger belongs to no schema.

This follows the design suggested in the issue:

  • The scope policy keeps an event trigger when it has an edge to a function in a selected schema ({ all: [{ kind: "eventTrigger" }, { edgeTo: { kind: "function", schema: selected } }] }). The Supabase profile's own rules still run after it, so the platform issue_*, pgrst_* and graphql_watch_* event triggers stay excluded.
  • When a scoped run filters out an added or changed object that belongs to no schema, the adapter reads pg-delta's plan.filteredDeltas and reports it as a schema_scope_excluded warning, and the CLI prints one line naming those objects with a hint to run without --schema. Removals are not reported, since leaving unselected objects alone is the point of a scoped run. The warning is not a coverage code, so --strict-coverage does not block on it.

One limitation: a comment on a kept event trigger is still filtered, because the comment fact has no edge to the function. It is now named in the warning rather than dropped silently. Keeping it would need a parent-chain form of edgeTo in pg-delta's policy DSL.

A community member offered to take this issue earlier today and had not opened a branch yet; happy to close this in favor of their work if that is preferred.

Linked issue

Closes #7903

  • The linked issue is open and carries the open-for-contribution label (or I'm a Supabase maintainer).

Checklist

  • The PR title follows Conventional Commits (e.g. fix(cli): …).
  • Tests added or updated for the change.
  • From the repository root, pnpm check:all passes; relevant package tests pass for every touched workspace, and pnpm types:check passes for each touched TypeScript workspace (or workspace declaring it).

The last box is unchecked only because jactionlint is not installed locally, so lint:actions:check could not run; this PR touches no workflow files, and the other check:all tasks and the CLI unit suite pass.

🤖 Generated with Claude Code

A `--schema` run excluded every change whose object is not in a selected
schema, so an event trigger was always left out without a word. Keep an
event trigger when its function is in a selected schema, and warn about
added or changed objects that belong to no schema and were filtered out.

Closes supabase#7903

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@martijn00
martijn00 requested a review from a team as a code owner December 1, 2026 22:18
@martijn00
martijn00 requested a review from mdonnalley December 1, 2026 22:18

This branch has not been deployed

No deployments
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.

db schema declarative sync -s: event triggers are silently left out of a schema-scoped run

1 participant