PostgreSQL 18 does not work
Opened this issue · 10 comments
Describe the Bug
PostgreSQL 18 is buggy with PayloadCMS 3.57.0. It has been released a few days ago if I'm not mistaken. The solution is to use PostgreSQL 17, at least in my case. So maybe the docker-compose.yml from the examples or the docs should be wary of this. I don't know if this is something that can be fixed in PayloadCMS.
Just informing this because I went almost crazy all day trying to figure out the source of this error, and it was the latest version of PostgreSQL all along, seems to introduce breaking changes
✓ Compiled / in 1128ms (758 modules)
[✓] Pulling schema from database...
⨯ Error: Failed query: ALTER TABLE "payload_preferences_rels" DROP CONSTRAINT "payload_preferences_rels_id_not_null";
params:
at async HomePage (src/app/(frontend)/page.tsx:13:18)
11 | const headers = await getHeaders()
12 | const payloadConfig = await config
> 13 | const payload = await getPayload({ config: payloadConfig })
| ^
14 | const { user } = await payload.auth({ headers })
15 |
16 | const fileURL = `vscode://file/${fileURLToPath(import.meta.url)}` {
query: 'ALTER TABLE "payload_preferences_rels" DROP CONSTRAINT "payload_preferences_rels_id_not_null";',
params: [],
payloadInitError: true,
digest: '4011555175',
[cause]: error: column "id" is in a primary key
Link to the code that reproduces this issue
Reproduction Steps
Steps:
- Start a new PayloadCMS project with a basic template.
- Deploy a new database with PostgreSQL 18 (using
image: postgres:latestin docker-compose.yml) - Configure PayloadCMS to use this database
- Get the database running
pnpm run devto open PayloadCMS- Try to add a simple text field to any of the default collections
- Errors such as "ALTER TABLE .... DROP CONSTRAINT" and "column "id" is in a primary key" all over the place with Drizzle. Manual migrations work good.
Which area(s) are affected? (Select all that apply)
db-postgres
Environment Info
Postgres 18.0
Binaries:
Node: 24.8.0
npm: N/A
Yarn: N/A
pnpm: 10.13.1
Relevant Packages:
payload: 3.57.0
next: 15.4.4
@payloadcms/db-postgres: 3.57.0
@payloadcms/email-nodemailer: 3.57.0
@payloadcms/graphql: 3.57.0
@payloadcms/next/utilities: 3.57.0
@payloadcms/payload-cloud: 3.57.0
@payloadcms/richtext-lexical: 3.57.0
@payloadcms/translations: 3.57.0
@payloadcms/ui/shared: 3.57.0
react: 19.1.0
react-dom: 19.1.0
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Tue, 23 Sep 2025 13:40:26 +0000
Available memory (MB): 32015
Available CPU cores: 16
Please add a reproduction in order for us to be able to investigate.
Depending on the quality of reproduction steps, this issue may be closed if no reproduction is provided.
Why was this issue marked with the invalid-reproduction label?
To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository created with create-payload-app@latest -t blank or a forked/branched version of this repository with tests added (more info in the reproduction-guide).
To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue. Ensure your reproduction does not depend on secrets, 3rd party registries, private dependencies, or any other data that cannot be made public. Avoid a reproduction including a whole monorepo (unless relevant to the issue). The easier it is to reproduce the issue, the quicker we can help.
Please test your reproduction against the latest version of Payload to make sure your issue has not already been fixed.
I added a link, why was it still marked?
Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.
Useful Resources
Same issue here, new to payloadcms, but this was killer, we needed to reset the database between nearly all changes. Thanks for the heads up, reverting to postgres 17 fixed the issue for us.
This is a killer problem, also cannot develop on 18 and had to drop to 17.
Can confirm downgrade PG to v17 solved the issue.
Phew thought I was going crazy there, yes downgrading to 17 solved breaking between every schema change
Phew thought I was going crazy there, yes downgrading to 17 solved breaking between every schema change
I actually ended up being crazy in the process my brother 🤣, so in order to avoid other people to go through hell like I did, I created this issue.
Speaking of which, I find interesting that PayloadCMS didn't enforce postgre 17 at least for create-payload-cms, which is the one I've used to learn and deploy Payload a month ago. New users must be growing white hair.
edit: seems that a pull request has been submitted #14332
Yes it was also painful for me. Props to @Arecsu for giving visibility to the issue and providing a solution.
It appears when this was introduced, Postgres16 was the :latest and the auto upgrade Postgres17 didn't seem to be an issue. Hindsight shows this should have been pinned from the get go.
Things to do now probably
- Check if there other images pinned to :latest that could at any moment break some setups?
Mongodb's image is also pinned to:latest. - Add notices that there are issues with Postgres18 to the storage adapter's README file and the Postgres doc page.
Note: Searching for :latest in the codebase I found this reference to a "Custom postgres 17 docker image" I will have a look at it
Here is:
- the related issue at Drizzle's
- news about an upcoming patch that should fix issues with drizzle+postgres18
- the upcoming patch trying to make its way into beta (it's a big one...)