You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add support for trigger comments, trigger enabled/disabled state, and sequence comments (#479)
* feat: detect and emit trigger comments, trigger enabled/disabled state, and sequence comments
- Trigger comments: inspect COMMENT ON TRIGGER via pg_description, emit COMMENT ON TRIGGER DDL on diff
- Trigger state: inspect trigger enabled flag (pg_trigger.tgenabled), emit ALTER TABLE ENABLE/DISABLE TRIGGER on diff
- Sequence comments: inspect COMMENT ON SEQUENCE via pg_description, emit COMMENT ON SEQUENCE DDL on diff
- Test fixtures: add_trigger_comment, add_sequence_comment, disable_trigger (all passing)
* fix: emit COMMENT ON SEQUENCE for SERIAL-owned sequences created via CREATE TABLE
When a table with BIGSERIAL/SERIAL columns was created for the first time,
pgschema skipped the sequence from addedSequences (correctly, since CREATE TABLE
creates it implicitly), but this also skipped emitting any COMMENT ON SEQUENCE
declared in the model. On the second run, the sequence existed in the live DB
and the comment diff fired, re-applying all sequence comments indefinitely.
Fix: track skipped-but-commented SERIAL sequences in addedSerialSeqComments and
emit their COMMENT ON SEQUENCE statements after all CREATE TABLE calls complete.
Test: add_serial_sequence_comment_on_create fixture verifies COMMENT is emitted
on first deploy alongside CREATE TABLE, not deferred to a subsequent run.
* fix: address Greptile review findings and add missing plan test files
Greptile fixes:
- ir/ir.go: rename Enabled bool → Disabled bool (omitempty) so zero-value means
enabled, matching Postgres default; avoids spurious DISABLE TRIGGER on triggers
that omit the field
- ir/inspector.go: set Disabled=true only when tgenabled='D'
- internal/diff/trigger.go: update all !trigger.Enabled → trigger.Disabled;
add DISABLE TRIGGER emission to view trigger create path (was missing)
- internal/diff/table.go: update Enabled → Disabled in trigger diff detection
- internal/diff/view.go: emit trigger comment and disabled state in both
constraint-recreate and non-constraint modify paths for view triggers
CI fix:
- Add plan.sql, plan.json, plan.txt for all 4 new fixtures so TestPlanAndApply passes
* fix: address Copilot review comments on trigger comment/state handling
- Re-apply trigger comment and disabled state after structural recreation
in table diff to avoid losing them on DROP+CREATE
- Use old/new comparison in view trigger modification branches to handle
comment removal and disabled->enabled transitions correctly
- Pass diffType to generateTriggerEnabledState so view trigger enable/disable
steps are correctly labeled as DiffTypeViewTrigger in plan output
0 commit comments