Issue: Error during `db:push` - TypeError in Drizzle Kit with PostgreSQL
Hi everyone,
I'm encountering a persistent issue when running the
pnpm db:push
command to push my PostgreSQL schema using drizzle-kit
. The process fails with a TypeError
related to replace()
in [email protected]
. Below are the details:
#### Error Output:
#### My Setup:
- Drizzle ORM: v0.35.3
- Drizzle Kit: v0.26.2
- Postgres: v3.4.4
- Node.js: v18.20.4
#### Drizzle Config (drizzle.config.ts
):
2 Replies
#### What I've Tried:
1. Schema Inspection for
Sample results: I suspect this (or a similar
CHECK
Constraints:
- I ran a query to check for any CHECK
constraints in my PostgreSQL schema, as I suspected the error might be related to them. Here's what I found:
Sample results: I suspect this (or a similar
CHECK
) constraint might be causing the issue.
2. Tried Downgrading/Upgrading drizzle-kit
:
I tried downgrading and upgrading drizzle-kit
but the issue persists with the same error.
3. Checked Permissions:
I also ensured that my PostgreSQL user has sufficient permissions to modify the schema and drop constraints.
#### Next Steps:
- Is there a known issue with drizzle-kit
handling complex CHECK
constraints like the one in pgsodium.key
?
- Should I manually drop these constraints before running db:push
, or is there a workaround to handle this within Drizzle ORM?
- Any insights or potential fixes from the community would be greatly appreciated!
Thanks in advance for your help!Hey @Jackson Kasi ,
I have faced the same error, when updating my schema, (
pnpm drizzle-kit pull
).
I think instead of using the 'postgres' driver to query the DB, try using 'pg' driver to query. Doing so solved my issue.
https://www.npmjs.com/package/pgnpm
pg
PostgreSQL client - pure javascript & libpq with the same API. Latest version: 8.13.0, last published: a month ago. Start using pg in your project by running
npm i pg
. There are 10200 other projects in the npm registry using pg.