Skip to content

Fix PostgreSQL migration dependency order - #31

Open
joe-thom wants to merge 2 commits into
mainfrom
joe-thom/fix-postgres-statement-order
Open

joe-thom wants to merge 2 commits into
mainfrom
joe-thom/fix-postgres-statement-order

Conversation

@joe-thom

@joe-thom joe-thom commented Sep 8, 2026

Copy link
Copy Markdown

Summary

PostgreSQL migrations now create columns before primary keys that use them. They also create parent uniqueness before dependent foreign keys.

Why

The 0.32.x differ can emit a replacement primary key before its new column. It can also emit a foreign key before its required uniqueness. PostgreSQL rejects both orders.

References CLO2-227

What changed

  • Matches the dependency phases from Drizzle v1 RC4.
  • Adds regressions for primary-key and foreign-key ordering.
  • Adds the ordering fix to the 0.32.4 changelog without changing the package version.

Validation

  • All 32 PostgreSQL table-diff tests pass.
  • Both generated migration sequences execute against PostgreSQL after the existing manual primary-key drop step.
  • The package typecheck and repository format check pass.

Stack

Merge bottom to top:

  1. Fix PostgreSQL migration dependency order聽#31 PostgreSQL migration dependency order (this PR)
  2. Handle PostgreSQL JSON expression defaults聽#33 JSON and JSONB expression defaults
  3. Batch PostgreSQL constraint introspection聽#34 batched constraint introspection
  4. Prepare drizzle-kit 0.32.4 release聽#35 0.32.4 release

Rollout and rollback

This layer does not publish a package or change a consumer. Reverting it restores the prior statement order.

~ written by Zerg 馃懢 (wp-e307c37c)

@joe-thom joe-thom added the zergling-authored Authored by a Zerg zergling label Sep 8, 2026
@joe-thom
joe-thom marked this pull request as ready for review September 10, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

zergling-authored Authored by a Zerg zergling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants