Comments (5)
I can share a few more helpful pieces of information:
1. The migration that is generated does not include a CREATE SCHEMA
statement.
Note that the migration file generated below was created with pnpm run payload migrate:create
using the following adapter config, AND that I have truncated the create statements since there are a lot:
db: postgresAdapter({
pool: {
connectionString: process.env.DATABASE_URI || '',
},
schemaName: 'template_payload_nfc_app'
}),
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
export async function up({ payload }: MigrateUpArgs): Promise<void> {
await payload.db.drizzle.execute(sql`
CREATE TABLE IF NOT EXISTS "template_payload_nfc_app"."nfc_tags" (
"id" serial PRIMARY KEY NOT NULL,
"xuid" varchar NOT NULL,
"active" boolean NOT NULL,
"tag_name" varchar,
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
);
CREATE TABLE IF NOT EXISTS "template_payload_nfc_app"."nfc_tags_rels" (
"id" serial PRIMARY KEY NOT NULL,
"order" integer,
"parent_id" integer NOT NULL,
"path" varchar NOT NULL,
"media_gallery_id" integer
);
CREATE TABLE IF NOT EXISTS "template_payload_nfc_app"."users" (
"id" serial PRIMARY KEY NOT NULL,
"admin" boolean,
"name" varchar,
"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
);
`);
};
export async function down({ payload }: MigrateDownArgs): Promise<void> {
await payload.db.drizzle.execute(sql`
DROP TABLE "template_payload_nfc_app"."nfc_tags";
DROP TABLE "template_payload_nfc_app"."nfc_tags_rels";
DROP TABLE "template_payload_nfc_app"."users";
DROP TABLE "template_payload_nfc_app"."media_gallery_media_items";
DROP TABLE "template_payload_nfc_app"."media_gallery";
DROP TABLE "template_payload_nfc_app"."media_gallery_rels";
DROP TABLE "template_payload_nfc_app"."uploads";
DROP TABLE "template_payload_nfc_app"."payload_preferences";
DROP TABLE "template_payload_nfc_app"."payload_preferences_rels";
DROP TABLE "template_payload_nfc_app"."payload_migrations";`);
};
2. The generated JSON file does not include entries in the schemas
field
Once again, I have not pasted the entire file - just the end of it
{
"id": "3af332c8-094a-443d-a20e-410d184c2bbb",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "5",
"dialect": "pg",
"tables": {...}, // tables are here, correctly. omitted for illustration & brevity
"enums": {},
"schemas": {},
"_meta": {
"schemas": {}, // there should be stuff here for a schema, but there is not.
"tables": {},
"columns": {}
}
}
from payload.
This might be related to #5473
I am investigating this.
from payload.
I think this problem is coming from drizzle-kit. I'm waiting on answers from their team.
from payload.
@DanRibbens
I've read that creating anyTable
in public
schema would fix the Drizzle issue. While it didn't fix it, now it tries to push the tables into the schema, however it's actually pushing to public
, even after specifying custom schema in both Payload and Drizzle configs. Then after going through all the db push prompts successfully:
+ 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 db.execute(import_drizzle_orm9.sql.raw(query));
and they're being logged just before execution:
// 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 public
first and only then looking for other schemas and eventually not finding them.
from payload.
I think this problem is coming from drizzle-kit. I'm waiting on answers from their team.
Probably not, I have used drizzle and drizzle-kit with non-default schemas (not the public
schema) in numerous other projects without payload. It is either a payload issue, or an issue with how payload is using drizzle.
from payload.
Related Issues (20)
- db-postgres: relationship field filterOptions returning unexpected results HOT 3
- Unpublish doesn't work in edit modal for relations field
- Error when parsing large amounts of JSON
- Filter "is not equal to" does not work for relationship field HOT 1
- Module parse failed: Unexpected character '#' in .mdx files HOT 2
- bug(admin): Admin view of Blocks nested within a Page don't load default locale data HOT 5
- Data is immediately published even though updating with `draft: true` option
- Payload not working anymore after upgrade to newest version HOT 3
- (db-postgres): Current method for counting rows in findMany / count operations is very heavy for tables with high amount of records. HOT 1
- "Delete" function deletes more than what's selected when using "Select all"
- Docker cannot Build without access to database - ERROR (payload): Error: cannot connect to MongoDB. Details: getaddrinfo ENOTFOUND mongo HOT 1
- Broken Link HOT 1
- Illustrator file is not uploadable HOT 1
- Breaking: MongoDb - Versions cast the "parent" key incorrectly
- [3.0.0-beta.30] Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components HOT 6
- [v3.0.0-beta.32] Has Many - Polymorphic Relationship Field ID Conflicts Across Collections Using PostgreSQL Adapter
- Can't Filter by Related Field? Postgres Bug? HOT 1
- Cloud storage plugin socket usage at capacity HOT 4
- No scroll to error when saving within globals or collections
- Can't change page size in drawer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from payload.