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
24.01k stars 606 forks source link

[BUG]: drizzle-kit push, migrate not working for neon #3128

Open samuelgja opened 1 week ago

samuelgja commented 1 week ago

What version of drizzle-orm are you using?

"drizzle-orm": "0.34.1",

What version of drizzle-kit are you using?

"drizzle-kit": "0.25.0"

Describe the Bug

When using migration, it not work for the neon db. This is my drizzle.config.ts

import { defineConfig } from 'drizzle-kit'

export default defineConfig({
  schema: './src/tables',
  out: './drizzle',
  dialect: 'postgresql', // 'postgresql' | 'mysql' | 'sqlite'
  dbCredentials: {
    url: envLoader.getEnv('DATABASE_URL'),
  },
})

Basically when run drizzle-kit migrate it return PostgresError: connection is insecure (try usingsslmode=require) Issue is 99% because of drizzle.config.ts using some default postgree client instead of neon one.

Only migrate.ts like this works:

import 'dotenv/config'
import { migrate } from 'drizzle-orm/neon-http/migrator' // neon client 
import { db } from './connection'
// This will run migrations on the database, skipping the ones already applied
migrate(db, { migrationsFolder: './drizzle' }).then(async () => {})

Expected behavior

all drizzle-kit commands should works as expected, maybe by defining somewhere neon in drizzle.config.ts? If there is such option, please close and sorry for this :)

Thank you.

Environment & setup

No response

juanvilladev commented 6 days ago

Also having issues with migrate hanging for Neon.