Skip to content

Commit

Permalink
fix: drizzle init args (#8818)
Browse files Browse the repository at this point in the history
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 🤔
  • Loading branch information
denolfe authored Oct 22, 2024
1 parent 2908c9a commit 9fb8665
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/db-postgres/src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
3 changes: 2 additions & 1 deletion packages/db-vercel-postgres/src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down

0 comments on commit 9fb8665

Please sign in to comment.