From 9fb86655a96ec4a53cb0a0b6edcf2aef4d897bd8 Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Mon, 21 Oct 2024 21:39:37 -0400 Subject: [PATCH] fix: drizzle init args (#8818) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adjust drizzle init for changes in drizzle 0.35.0 https://github.com/drizzle-team/drizzle-orm/releases/tag/0.35.0 The pool/connection should now be passed as the `client` arg when initializing drizzle. ```ts this.drizzle = drizzle({ client: this.poolOptions ? new VercelPool(this.poolOptions) : sql, logger, schema: this.schema, }) ``` This was causing an issue where running `payload migrate` on Vercel was causing drizzle to attempt to `127.0.0.1:5432` instead of the specified environment variable in the adapter 🤔 --- packages/db-postgres/src/connect.ts | 2 +- packages/db-vercel-postgres/src/connect.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/db-postgres/src/connect.ts b/packages/db-postgres/src/connect.ts index 37c077c0f3d..032ba7ba91b 100644 --- a/packages/db-postgres/src/connect.ts +++ b/packages/db-postgres/src/connect.ts @@ -66,7 +66,7 @@ export const connect: Connect = async function connect( } const logger = this.logger || false - this.drizzle = drizzle(this.pool, { logger, schema: this.schema }) + this.drizzle = drizzle({ client: this.pool, logger, schema: this.schema }) if (!hotReload) { if (process.env.PAYLOAD_DROP_DATABASE === 'true') { diff --git a/packages/db-vercel-postgres/src/connect.ts b/packages/db-vercel-postgres/src/connect.ts index 1da8676f9aa..1039db72cf1 100644 --- a/packages/db-vercel-postgres/src/connect.ts +++ b/packages/db-vercel-postgres/src/connect.ts @@ -26,7 +26,8 @@ export const connect: Connect = async function connect( const logger = this.logger || false // Passed the poolOptions if provided, // else have vercel/postgres detect the connection string from the environment - this.drizzle = drizzle(this.poolOptions ? new VercelPool(this.poolOptions) : sql, { + this.drizzle = drizzle({ + client: this.poolOptions ? new VercelPool(this.poolOptions) : sql, logger, schema: this.schema, })