Skip to content

declarative: sync command always generates a migration for a trigger that does not change in any way #5094

@tolgap

Description

@tolgap

Describe the bug
I'm using the pre-release version with the pgmq changes. The declarative generate now works correctly. The sync command also no longer crashes.

But when using sync without changing anything, always seems to try and generate a migration for a trigger that simply does not change at all.

To Reproduce
Steps to reproduce the behavior:

  1. Run supabase db schema declarative generate --local
  2. Run supabase db schema declarative sync
  3. Observe that it tries to generate a migration for a trigger that already exists in the DB 1to1

Expected behavior

Given a migration file with:

# migrations/01_initial.sql
create trigger "trg_update_priority_scores"
before insert or update of visitors_total_count, start_date, background_images, priority_override_score
on "my_schema"."tournaments"
for each row
execute function "my_schema"."update_priority_scores"();

And a schema file:

# database/schema/my_schema/tables/tournaments.sql
CREATE TRIGGER trg_update_priority_scores
  BEFORE INSERT OR UPDATE OF visitors_total_count, start_date, background_images, priority_override_score ON my_schema.tournaments
  FOR EACH ROW
  EXECUTE FUNCTION my_schema.update_priority_scores();

I would have expected nothing to be generated.

But instead
The declarative commands generates only this migration:

# migrations/20260416140754_declarative_sync.sql
CREATE OR REPLACE TRIGGER trg_update_priority_scores BEFORE INSERT OR UPDATE OF visitors_total_count, start_date, background_images, priority_override_score ON my_schema.tournaments FOR EACH ROW EXECUTE FUNCTION my_schema.update_priority_scores();

When I

  • apply this generated migration to my db
  • rerun the sync command again
  • it, again, generates a migration with the same exact trigger

Screenshots
If applicable, add screenshots to help explain your problem.

System information
Rerun the failing command with --create-ticket flag.

  • Version of OS: MacOS 26.4.1
  • Version of CLI: v2.91.2
  • Version of Docker: v4.69.0
  • Versions of services: [output from supabase services command]
   SERVICE IMAGE          | LOCAL                  | LINKED 
  ------------------------|------------------------|--------
   supabase/postgres      | 15.8.1.085             | -      
   supabase/gotrue        | v2.188.1               | -      
   postgrest/postgrest    | v14.8                  | -      
   supabase/realtime      | v2.82.0                | -      
   supabase/storage-api   | v1.48.28               | -      
   supabase/edge-runtime  | v1.73.3                | -      
   supabase/studio        | 2026.04.08-sha-205cbe7 | -      
   supabase/postgres-meta | v0.96.4                | -      
   supabase/logflare      | 1.37.1                 | -      
   supabase/supavisor     | 2.7.4                  | -      

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions