Drizzle Team

DT

Drizzle Team

The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!

Join

Does Drizzle support using INSERT statements in a WITH clause?

I've attempted to write the following postgres query with Drizzle multiple ways, but ultimately haven't found a suitable replacement for the templated SQL: ``typescript const query = await db.execute(sql WITH "new_thread" AS ( INSERT INTO...

drizzle-kit defineConfig no "pg" driver available.

There seems to be no type for "pg" in the driver field of defineConfig in drizzle-kit. ```ts import { defineConfig } from "drizzle-kit" ...

Multiple files schemas with query to Access data

I want to use query but I heard you have to import every schemas to use query. Is there a way to import every files in that folder instead of doing this below: ``` import * as schema1 from './schema1'; import * as schema2 from './schema2';...

Migrations taking the first snapshot

I'm running migration like how it says in the docs, but for some reason it keeps trying to use the first migrations file generated even after running generate ```ts import "dotenv/config"; ...
No description

NeonDbError: Error connecting to database: fetch failed

i get this ^ error on my laptop which runs linux but not my desktop which runs windows. how do i fix it?

getting the initialize drizzle types.

I wanted to do some backend crud. im not sure how to get the initialize db types of drizzel any knows how? ``` import { db } from "@utils/turso/clients"; const api = apiCrud({ client: db,...

LibsqlError: SQLITE_BUSY: database is locked

I am getting a LibsqlError: SQLITE_BUSY: database is locked error on my insert function here with LibSQL/Turso as my SQLite driver ```ts export async function putClientGroup( clientGroup: ClientGroupRecord, ): Promise<void> {...

Convert PostgreSQL to Drizzle ORM

I have the following SQL that I am trying to convert to Drizzle ORM for my NextJS project. ```sql SELECT ffxiv_blue_mage_tracker_spells.id,...
Solution:
That helped. Thank you

Cannot use 'in' operator to search for 'enumValues' in undefined

This is suddenly issue - I haven't changed anything in my schema, I just updated to the newest version of drizzle/drizzle-kit ```ts export const user = pgTable('user', { id: serial('id').primaryKey(),...

how to properly close mysql pool connection?

Just wanted to add a migrate.ts file, and got this out a example: ```import "dotenv/config" import { migrate } from "drizzle-orm/mysql2/migrator" import db from "@/app/db/drizzle"...

Top-level await in drizzle.config.ts

Is there a reason top-level await is only supported in migrate/studio commands and not generate/check, is this something that can be trivially added to drizzle-kit? In my case I'm reading the secret asynchronously via AWS. There's an open issue with a workaround posted, which does work, but is kind of gross: https://github.com/drizzle-team/drizzle-orm/issues/1982#issuecomment-2112340840...

Drizzle with Zod throws type errors with simple `numeric` example

For example, I define a PostgreSQL table with an input schema: ``` export const Foo = pgTable('foo', { bar: numeric('bar'), });...

Why is it the case that my IDE says `await` does nothing on pretty much every single function?

I'm trying to setup a startup script that creates a local db and seeds it when I start my project. I'm running into an error where db is just not defined or has undefined columns. I'm debugging, and I can't help but notice that my IDE says await does nothing on the migrate function or any of the db.select() calls....

How to do and "inArray" with a dinamic array?

I did this on the code and is working well, the things is that it throws and error and idk how to fix it
No description

too many clients already, remaining slots reserved for superuser

I have a production deployment where I'm facing this issue. I ran SELECT count(*) FROM pg_stat_activity and noticed that there are indeed 100 connections which is the max. However, I noticed most of them are idle. Temporarily I've increased the max_connections to 500. I have couple of questions to which I'm not getting straightforward answers: 1. Why are there so many idle connections? I understand if there are many active connections. But why idle? 2. If there are that many idle connections, shouldn't the connection pool of postgres.js kick in as it says here (https://github.com/porsager/postgres?tab=readme-ov-file#the-connection-pool) that the previous open connection will be used? So my understanding is that the idle connections will be made active with the new queries. Why isn't that happening? 3. Will I have to manually set the idle_timeout and max_lifetime values to lower and optimal values for my use case to get rid of idle connections? 4. Along with the increasing max_connections, should I increase anything else? Do I need something like pg_bouncer and how would that help?...

Weird freeze in code, seemingly stalling on drizzle query

My function runs a few queries to the database, but they don't seem to basically ever finish. I don't know what it's caused by, i have tried fully resetting the database and creating only the user/database and running the migrations and that didn't help. The function is run lots of times concurrently, so there's probably around a 1000 queries being ran at the same time. I know it's not ideal for performance, and i am planning to fix it soon, but i don't think it should be causing issues.
No description

Typescript Error

Anyone know why this is happening? I upgraded my drizzle version so maybe something changed?
No description

Warning: You need to pass an instance of Client:Client

Could someone explain / show me what changes I need to apply to the config file? Thanks in advance! drizzle-kit push: ``` ❯ pnpm drizzle-kit push --config=.../drizzle.config.ts...

Prepared insert statement with customType

When using prepared insert statement with customType the Placeholder object gets passed to the toDriver of the custom type. How do I resolve it? Schema: ```ts export const sessionSchema = pgTable('session', {...

Drizzle ORM + Supabase Enforce SSL

I'm trying to connect with a direct pool connection (transaction mode). I'm deploying to Supabase Deno functions. This is my URL: postgres://postgres.{user}:[YOUR-PASSWORD]@aws-0-us-west-1.pooler.supabase.com:6543/postgres const client = postgres(url, { prepare: false }); const db = drizzle(client);...
Next