Jackson Kasi
Jackson Kasi
Explore posts from servers
DTDrizzle Team
Created by Jackson Kasi on 10/22/2024 in #help
Issue: Error during `db:push` - TypeError in Drizzle Kit with PostgreSQL
#### What I've Tried: 1. Schema Inspection for 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:
SELECT conname, pg_get_constraintdef(oid) as constraint_definition
FROM pg_constraint
WHERE contype = 'c';

SELECT conname, pg_get_constraintdef(oid) as constraint_definition
FROM pg_constraint
WHERE contype = 'c';

Sample results:
{
"constraint_name": "pgsodium_raw",
"schema_name": "pgsodium",
"table_name": "key",
"constraint_definition": "CHECK (CASE WHEN (raw_key IS NOT NULL) THEN ((key_id IS NULL) AND (key_context IS NULL) AND (parent_key IS NOT NULL)) ELSE ((key_id IS NOT NULL) AND (key_context IS NOT NULL) AND (parent_key IS NULL)) END)"
}

{
"constraint_name": "pgsodium_raw",
"schema_name": "pgsodium",
"table_name": "key",
"constraint_definition": "CHECK (CASE WHEN (raw_key IS NOT NULL) THEN ((key_id IS NULL) AND (key_context IS NULL) AND (parent_key IS NOT NULL)) ELSE ((key_id IS NOT NULL) AND (key_context IS NOT NULL) AND (parent_key IS NULL)) END)"
}

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!
3 replies