fix: drizzle init args (#8818)

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 🤔
This commit is contained in:
Elliot DeNolf
2024-10-21 21:39:37 -04:00
committed by GitHub
parent 2908c9adde
commit 9fb86655a9
2 changed files with 3 additions and 2 deletions

View File

@@ -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') {

View File

@@ -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,
})