-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.0 Beta] Changes not applying to tables when using schemaName #5822
Comments
This might be related to #5473 I am investigating this. |
I think this problem is coming from drizzle-kit. I'm waiting on answers from their team. |
@DanRibbens + users table will be created
+ payload_preferences table will be created
+ payload_preferences_rels table will be created
+ payload_migrations table will be created
--- all table conflicts resolved --- I'm getting the same error: ⨯ Internal error: error: schema "payload" does not exist
at /node_modules/pg-pool/index.js:45:11
... These are the queries I'm passing to be executed in // node_modules/drizzle-kit/payload.js
DrizzleORMPgClient = class extends DrizzleDbClient {
async query(query, values) {
console.log("console.log(query):", query)
const res = await this.db.execute(import_drizzle_orm9.sql.raw(query));
return res.rows;
}
async run(query) {
console.log("I'm not being logged out due to error. :(")
const res = await this.db.execute(import_drizzle_orm9.sql.raw(query));
return res.rows;
}
}; Output: console.log(query): select count(*) as count from "anyTable"
# no CREATE SCHEMA here
console.log(query): CREATE TABLE IF NOT EXISTS "payload"."users" (
"id" serial PRIMARY KEY NOT NULL,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"email" varchar NOT NULL,
"reset_password_token" varchar,
"reset_password_expiration" timestamp(3) with time zone,
"salt" varchar,
"hash" varchar,
"login_attempts" numeric,
"lock_until" timestamp(3) with time zone
);
⨯ Internal error: error: schema "payload" does not exist
at /node_modules/pg-pool/index.js:45:11
... So it looks like Drizzle is pointing to |
Probably not, I have used drizzle and drizzle-kit with non-default schemas (not the |
I can share a few more helpful pieces of information: 1. The migration that is generated does not include a
|
still doesn't respect schemaName |
db: postgresAdapter({
pool: {
connectionString: process.env.DATABASE_URI || '',
},
schemaName: "payload",
}), ⨯ unhandledRejection: error: there is no parameter $1
at eval (webpack-internal:///(rsc)/./node_modules/pg-pool/index.js:45:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async DrizzleORMPgClient.query (/home/alsherif/New_Dev/dr-brand-backend-storefront/node_modules/drizzle-kit/payload.js:34498:21)
at async /home/alsherif/New_Dev/dr-brand-backend-storefront/node_modules/drizzle-kit/payload.js:2259:46 {
length: 95,
severity: 'ERROR',
code: '42P02',
detail: undefined,
hint: undefined,
position: '175',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_expr.c',
line: '842',
routine: 'transformParamRef'
} |
The problem right now with schema name is that if you have other tables with the same name in other schemas they will conflict. It only works if each schema is using uniquely named table and enums. We're waiting on a fix from drizzle. |
@DanRibbens do you know if there is any update for this issue? I'm experiencing the same issue and it would be nice to be able to add payload with an existing project to accelerate the content creation via the CMS. |
I have also encountered this bug. @DanRibbens might be right. This obviously prevents any attempts at trying to make two separate Payload CMS instances with collections with duplicate names access the same database, which is what I was trying to do. If for example you have a schema "public" and "test", both with the collection "users", only the Payload CMS instance that tries to access the "public" schema will work, and the other will throw something like the following when attempting to run it locally or anywhere else:
I guess this could be resolved if there was a way to add a prefix/suffix to all tables that payload accesses inside the postgresAdapter options, but that would be quite an ugly hack. |
@hansfuchs |
I pinged our drizzle friends about this, waiting on a fix. |
any update on this? I'd love to use Payload as CMS for our customers but this is kind of a deal breaker... |
This was fixed here: #7453 |
This issue has been automatically locked. |
Link to reproduction
No response
Describe the Bug
I've encountered a bug using payload-3.0-demo, where upon initializing Payload, a custom schema in my database is not being created. I've implemented it like so:
Here is the error after running simple
pnpm dev
:So I've created a schema with the specified name in my database and tables were properly created within it. I have the impression that this is a workaround for the problem, as when modifying the collection (e.g., changing the slug name in pages collection), I've received a similar error.
slug: "title" -> slug: "page_title"
To Reproduce
schemaName: "payload"
topayload.config.ts
pnpm dev
and go tolocalhost:3000/admin
Payload Version
3.0.0-beta.6
Adapters and Plugins
@payloadcms/db-postgres
The text was updated successfully, but these errors were encountered: