Skip to content

fix(postgres): support postgres 18 - #18372

Merged
SippieCup merged 2 commits into
sequelize:mainfrom
wikirik-agent:fix/postgres-18-ci
Sep 12, 2026
Merged

SippieCup merged 2 commits into
sequelize:mainfrom
wikirik-agent:fix/postgres-18-ci

Conversation

@wikirik-agent

@wikirik-agent wikirik-agent commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description of Changes

Split out of #18258, as requested in #18258 (comment).

Bumps the latest postgres container from postgis/postgis:17-3.5 to postgis/postgis:18-3.6. Two things were needed to make that work:

1. The volume mount had to move. The postgres 18 Docker images store data in a major-version-specific subdirectory and refuse to start when a volume is mounted at /var/lib/postgresql/data (see docker-library/postgres#1259):

Error: in 18+, these Docker images are configured to store database data in a
       format which is compatible with "pg_ctlcluster" ...
       Counter to that, there appears to be PostgreSQL data in:
         /var/lib/postgresql/data (unused mount/volume)

So dev/postgres/latest now mounts the volume at /var/lib/postgresql. dev/postgres/oldest (postgres 11) is untouched.

Anyone with an existing local sequelize-postgres-latest-volume needs yarn reset-postgres (or bash dev/postgres/latest/reset.sh) once, since the old volume holds a postgres 17 data directory.

2. ForeignKeyConstraintError stopped being raised for RESTRICT violations. Postgres 18 reports foreign key RESTRICT violations with SQLSTATE 23001 (restrict_violation) and a different message, where earlier versions used 23503:

postgres 17: ERROR:  23503: update or delete on table "p" violates foreign key constraint "c_pid_fkey" on table "c"
postgres 18: ERROR:  23001: update or delete on table "p" violates RESTRICT setting of foreign key constraint "c_pid_fkey" on table "c"

ON DELETE NO ACTION still reports 23503, so only RESTRICT is affected. formatError in packages/postgres/src/query.js now handles both codes and both message shapes, so the constraint name is still extracted and a ForeignKeyConstraintError is thrown.

That regression was caught by the existing integration tests — the can restrict deletes / can restrict updates tests for BelongsTo, BelongsToMany, HasOne and HasMany (8 failures) — which now pass again.

Verified locally against postgis/postgis:18-3.6 (PostgreSQL 18.6): yarn test-integration-postgres goes from 2087 passing / 8 failing to 2095 passing, 0 failing.

List of Breaking Changes

None.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of PostgreSQL 18 foreign-key restriction errors, including clearer constraint identification.
    • Updated PostgreSQL development configuration for compatibility with PostGIS 18.3.6.

Bumps the latest postgres container to 18. The postgres 18 images store
their data in a major-version-specific subdirectory, so the volume now
mounts at /var/lib/postgresql instead of /var/lib/postgresql/data.

Postgres 18 reports foreign key RESTRICT violations with SQLSTATE 23001
(restrict_violation) and a "violates RESTRICT setting of foreign key
constraint" message, where earlier versions used 23503. Without handling
that, those errors surfaced as a plain DatabaseError instead of a
ForeignKeyConstraintError.

Co-Authored-By: Claude Opus 5 <[email protected]>
@wikirik-agent
wikirik-agent requested a review from a team as a code owner September 12, 2026 07:43
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 9ccf399a-4e78-4a94-a225-e64eeda953d4

📥 Commits

Reviewing files that changed from the base of the PR and between 6a84353 and a307011.

📒 Files selected for processing (2)
  • dev/postgres/latest/docker-compose.yml
  • packages/postgres/src/query.js

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The PostgreSQL development service now uses PostGIS 18-3.6. PostgreSQL error formatting now recognizes 23001 RESTRICT violations and extracts their constraint names.

Changes

PostgreSQL 18 compatibility

Layer / File(s) Summary
PostgreSQL 18 development environment
dev/postgres/latest/docker-compose.yml
The service uses postgis/postgis:18-3.6 and mounts the volume at /var/lib/postgresql.
PostgreSQL 18 foreign-key error mapping
packages/postgres/src/query.js
formatError maps 23001 errors to ForeignKeyConstraintError and parses PostgreSQL 18 RESTRICT constraint messages.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to cfcc0

No actionable merge-blocking risk remains in the PostgreSQL 18 compatibility changes.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding PostgreSQL 18 support, including the integration and foreign-key error handling updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@SippieCup SippieCup left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

been using pg18 for a few months now in prod.

@SippieCup
SippieCup enabled auto-merge (squash) September 12, 2026 12:33
@WikiRik

WikiRik commented Sep 12, 2026

Copy link
Copy Markdown
Member

I haven't reviewed the code change yet, but shouldn't really break anything. I do want to see if we can improve the detection when we migrate it to TS

@SippieCup
SippieCup merged commit 638dd04 into sequelize:main Sep 12, 2026
74 checks passed
@SippieCup

Copy link
Copy Markdown
Contributor

I haven't reviewed the code change yet, but shouldn't really break anything. I do want to see if we can improve the detection when we migrate it to TS

its just drop in and a change in how data is formatted in PG. the surface area is basically unchanged other than locking. support for uuidv7 is just baked in which is nice, and we should make v7 a first-class and default for uuids. but just setting default(sql(uuidv7()) works well enough for me for the past few months.

papandreou added a commit to papandreou/sequelize that referenced this pull request Sep 16, 2026
* origin/main: (66 commits)
  meta: update dependency @oclif/test to v4.2.0 (sequelize#18394)
  meta: update actions/setup-node action to v6.5.0 (sequelize#18391)
  meta: update actions/stale action to v10.4.0 (sequelize#18392)
  meta: update actions/checkout action to v6.1.0 (sequelize#18390)
  meta: update dependency zod to ^4.6.5 (sequelize#18386)
  meta: update mysql docker tag to v8.4.11 (sequelize#18387)
  meta(sqlite3): fix changeColumn foreign key  race condition. (sequelize#18383)
  meta: update icr.io/db2_community/db2 docker tag to v12.1.5.0 (sequelize#18385)
  meta: update gvenzl/oracle-free docker tag to v23.26.3 (sequelize#18384)
  meta: update sequelize AUTHORS (sequelize#18376)
  meta: update dependency umzug to ^3.8.3 (sequelize#18381)
  meta: update dependency zod to ^4.6.4 (sequelize#18382)
  meta: update dependency uuid to ^11.1.1 (sequelize#18380)
  meta: update dependency typescript to v6.0.3 (sequelize#18378)
  meta: update dependency typedoc-plugin-missing-exports to v4.1.4 (sequelize#18377)
  meta: update dependency typedoc to v0.28.20 (sequelize#18375)
  meta: update dependency tedious to ^19.2.2 (sequelize#18374)
  fix(postgres): support postgres 18 (sequelize#18372)
  meta: update dependency @oclif/plugin-help to ^6.3.0 (sequelize#18373)
  fix(postgres): correct changeColumn for enum arrays and enum defaults (sequelize#18361)
  ...

# Conflicts:
#	packages/postgres/src/query-generator.js
#	packages/postgres/src/query-interface.js

Co-Authored-By: Claude Sonnet 5 <[email protected]>
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.

3 participants