payloadcms / payload

The best way to build a modern backend + admin UI. No black magic, all TypeScript, and fully open-source, Payload is both an app framework and a headless CMS.
https://payloadcms.com
MIT License
21.1k stars 1.27k forks source link

postgres vercel column "prefix" does not exist #5788

Open Eric-Arz opened 2 months ago

Eric-Arz commented 2 months ago

Link to reproduction

No response

Describe the Bug

Hi,

we are having trouble when uploading files in production on Vercel because we always get this error:

error: column "prefix" does not exist at /var/task/node_modules/pg/lib/client.js:526:17 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async /var/task/node_modules/drizzle-orm/node-postgres/index.cjs:41:28 at async find (/var/task/node_modules/@payloadcms/db-postgres/dist/find/findMany.js:167:21) at async Object.findOne (/var/task/node_modules/@payloadcms/db-postgres/dist/findOne.js:20:22) at async docWithFilenameExists (/var/task/.next/server/chunks/3005.js:28:239681) at async getSafeFileName (/var/task/.next/server/chunks/3005.js:28:248633) at async generateFileData (/var/task/.next/server/chunks/3005.js:28:242926) at async create (/var/task/.next/server/chunks/3005.js:28:47026) at async handler (/var/task/.next/server/chunks/2537.js:1:1921) { length: 106, severity: 'ERROR', code: '42703', detail: undefined, hint: undefined, position: '21', internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'parse_relation.c', line: '3713', routine: 'errorMissingColumn' }

our media collection does indeed not have a prefix, so we don't understand why payload keeps trying to use it. Fully resetting our migration history and making a single clean new one didn't resolve the issue either. We can't use the latest version of db-postgres because of https://github.com/payloadcms/payload/issues/5589

Regards,

Eric

To Reproduce

setup a payload project with next-payload and db-postgres on vercel and try uploading a file

Payload Version

2.12.1

Adapters and Plugins

@payloadcms/db-postgres: 0.3.1

maneike commented 2 months ago

I've been experiencing a similiar issue. My guess is that it's a problem with Drizzle and custom schema names. Are you also using schemaName in the Payload config?

DanRibbens commented 2 months ago

@Eric-Arz, I am also curious about maneike's question. Are you using a cusotm schema name?

I'm curious if adding a drizzle.config.ts with schema and schemaFilter would fix this or your issue @maneikie?

https://orm.drizzle.team/kit-docs/config-reference#schemafilter

Let me know. I'm labeling this as a dependency issue for now, but we'll keep it open until we know more.

Last note, we're only going to fix this if it is an issue with payload v3, which is currently in beta. We're not addressing anything else related to next-payload.

maneike commented 2 months ago

@DanRibbens Thanks for digging in!

Even with such drizzle.config.ts, the issue persists:

import type { Config } from "drizzle-kit";

export default {
  schemaFilter: ["payload"],
  schema: ["payload"],
} satisfies Config;
Eric-Arz commented 2 months ago

@maneike no we are not using schemaName