drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
23.86k stars 593 forks source link

[BUG]: The Drizzle-kit push command consistently crashes on execution (Supabase | NeonDB | SST) #3156

Open ironbyte opened 16 hours ago

ironbyte commented 16 hours ago

What version of drizzle-orm are you using?

0.35.2

What version of drizzle-kit are you using?

0.26.2

Describe the Bug

I'm not really sure why I keep getting an error whenever I try to run drizzle:push": "sst shell drizzle-kit push". I've been able to reproduce this in both new and existing projects since March. I've always make sure my Drizzle deps are up to date.

Reading config file '/home/moncy/projects/kyros-labs/artemis/packages/core/drizzle.config.ts'
Using 'postgres' driver for database querying
[⣟] Pulling schema from database...
/home/moncy/projects/kyros-labs/artemis/node_modules/drizzle-kit/bin.cjs:19716
              checkValue = checkValue.replace(/^CHECK\s*\(\(/, "").replace(/\)\)\s*$/, "");
                                      ^

TypeError: Cannot read properties of undefined (reading 'replace')
    at /home/moncy/projects/kyros-labs/artemis/node_modules/drizzle-kit/bin.cjs:19716:39
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.18.0

image

Expected behavior

The command should work as expected in a project using Drizzle ORM with either Supabase or NeonDB as the DB service.

Environment & setup

NeonDB

import { defineConfig } from 'drizzle-kit'
import { Resource } from 'sst'

export default defineConfig({
    dialect: 'postgresql',
    schema: './src/schema/*',
    out: './migrations',
    dbCredentials: {
        url: Resource.DatabaseUrl.value,
        database: 'postgres',
        port: 5432,
    },
    verbose: true,
    strict: true,

    schemaFilter: ['public'],
})

import { neonConfig, Pool as NeonPool } from '@neondatabase/serverless'
import { drizzle as drizzleNeon } from 'drizzle-orm/neon-serverless'
import { Resource } from 'sst'
import ws from 'ws'

import * as schema from './schema'

neonConfig.webSocketConstructor = ws

export const neonDatabaseUrl = Resource.DatabaseUrl.value

export const db = drizzleNeon<typeof schema>(
    new NeonPool({ connectionString: neonDatabaseUrl }),
    {
        schema,
        // logger: Resource.App.stage !== 'production',
    },
)

export type DB = typeof db
    "@neondatabase/serverless": "^0.9.5",
    "drizzle-kit": "^0.26.2",
    "drizzle-orm": "^0.35.2",
    "drizzle-zod": "^0.5.1",
    "ws": "^8.18.0",
    "sst": "3.1.54"

Supabase

import { defineConfig } from 'drizzle-kit'
import { Resource } from 'sst'

export default defineConfig({
    dialect: 'postgresql',
    schema: './src/schema/*',
    out: './migrations',
    dbCredentials: {
        url: Resource.SupabaseDatabaseUrl.value,
        ssl: {
            rejectUnauthorized: false,
        },
    },
    verbose: true,
    strict: true,
    schemaFilter: ['public'],
})

import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
import { Resource } from 'sst'

import * as schema from './schema'

export const sql = postgres(Resource.SupabaseDatabaseUrl.value, {
    prepare: false,
    debug: true,
})

export const db = drizzle(sql, {
    schema,
})

export type DB = typeof db
    "drizzle-kit": "^0.26.2",
    "drizzle-orm": "^0.35.2",
    "drizzle-zod": "^0.5.1",
    "postgres": "^3.4.4",
    "sst": "3.1.54"

Linux (Fedora)

Linux moncy-lambda-pc 6.11.3-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Oct 10 22:31:19 UTC 2024 x86_64 GNU/Linux
jmontoyaa commented 3 hours ago

I have the same issue but with supabase + I use also fedora :thinking: