Skip to content

fix(pg-delta): support PostgreSQL 18 temporal constraints in extraction and diffing#186

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-postgresql-temporal-constraints-support
Draft

fix(pg-delta): support PostgreSQL 18 temporal constraints in extraction and diffing#186
Copilot wants to merge 2 commits intomainfrom
copilot/add-postgresql-temporal-constraints-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 10, 2026

PostgreSQL 18 adds temporal constraint semantics (WITHOUT OVERLAPS / PERIOD) that were not represented in pg-delta’s table constraint model. As a result, temporal and non-temporal constraint variants could compare as unchanged even when their semantics differed.

  • Constraint model + extraction

    • Add is_temporal to table constraint props.
    • Extract temporal metadata from pg_constraint.conperiod in a version-safe way using to_jsonb(c)->>'conperiod', defaulting to false on older PostgreSQL versions.
    • Preserve temporal constraint definitions through catalog export/introspection.
  • Constraint diffing

    • Include is_temporal in table constraint comparison.
    • Temporal ↔ non-temporal transitions now produce a drop/recreate path instead of a no-op.
  • PostgreSQL 18 coverage

    • Add catalog extraction coverage for temporal primary keys and foreign keys.
    • Add PG18 roundtrip coverage for:
      • converting a regular primary key to WITHOUT OVERLAPS
      • creating a temporal foreign key using PERIOD
  • Release note

    • Add a pg-delta patch changeset for PostgreSQL 18 temporal constraint support.

Example of the newly covered DDL:

CREATE TABLE test_schema.bookings (
  room_id integer NOT NULL,
  booking_period tstzrange NOT NULL,
  CONSTRAINT bookings_pkey
    PRIMARY KEY (room_id, booking_period WITHOUT OVERLAPS)
);

ALTER TABLE test_schema.booking_audit
  ADD CONSTRAINT booking_audit_room_id_booking_period_fkey
  FOREIGN KEY (room_id, PERIOD booking_period)
  REFERENCES test_schema.bookings (room_id, PERIOD booking_period);

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.postgresql.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 10, 2026

🦋 Changeset detected

Latest commit: b887413

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

Copilot AI changed the title [WIP] Add support for PostgreSQL temporal constraints in pg-delta fix(pg-delta): support PostgreSQL 18 temporal constraints in extraction and diffing Apr 10, 2026
Copilot AI requested a review from avallete April 10, 2026 17:14
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.

pg-delta: support PostgreSQL temporal constraints (WITHOUT OVERLAPS / PERIOD)

2 participants