Drizzle Team

DT

Drizzle Team

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

Join

Durable Object example weird import

Here in thd docs https://orm.drizzle.team/docs/connect-cloudflare-do There is the following import import migrations from '../drizzle/migrations'; which i dont get? Inside my drizzle folder i have the migration files *.sql and a meta folder. Where does the migrations file come from? ...

Error in Drizzle.studio

I'm having problems to get my drizzle studio up, one day it was working without any problem and the next day I started to get this problem, the versions I have are the following: "drizzle-orm": "0.33.0", "drizzle-kit": "^0.24.0", My configuration is as follows :...
No description

Is there any easy way to query both total count and pagination result?

The official doc shows a simple pagination query with dynamic query: ```ts function withPagination<T extends PgSelect>( qb: T,...

Hitting connection limits using Pgbouncer

I am connecting to my Supabase DB from my NextJS app hosted on Vercel and am pretty consistently hitting the max client connections when using PgBouncer. I have upgraded my Supabase project to use the IPV4 extension so that I can use the dedicated pooler, and I am running an XL DB. I am wondering if I am just initializing the DB incorrectly and am not properly releasing connections to the pooler? I also recently switched to the vercel fluid ocmpute model in hopes of releiving this issue. The postgres url being used is that of the dedicated pooler on port 6543! Curious if I need to update the way I am connecting in order to release connections back to the pooler? Or if my app traffic is just needed a larger DB....

Relationships not working? (Simplest one-one relationship)

I can't seem to have Drizzle return the correct query when using the relationship syntax. I have the following relationship defined: user-schema.ts ``` export const manager = mysqlTable('manager', { userId: varchar('user_id', { length: 36 }).notNull().references(() => user.id, { onDelete: 'cascade' }),...

Can't get Drizzle working in turborepo as package

I can't get Drizzle working as package in turborepo, getting all kind of TS errors. Does anyone have a working example? I am using Sveltekit as the frontend, hono as the backend (with nodeJS) and want to use a message queue worker (BullMQ in my case) too as a seperate app. Both Hono and the message queue will need to access drizzle, thats why I want to use Drizzle as a package....

Resolve drizzle-kit push wanting to truncate tables which do not need to be truncated

Is it possible to fix drizzle-kit push wanting to truncate by tables because it wants to change from bigint(20) to bigint? ``` Warning Found data-loss statements: · You're about to change id column type from bigint(20) to bigint with 1 items...

What does .all() do?

Half of the examples here: https://orm.drizzle.team/docs/joins use .all() at the end and half don't. There is no doc or anything mentioning .all() - Can someone please tell me?

reference table name as const

I'm looking for a way to reference a postgres table name as a const. getTableConfig(tableName).name returns the name as a string, while tableName._.name does not exist in runtime. Hopefully there's something that combines both, without needing for manual typecasting.

can someone help me with this relation?

export const Worklog = mysqlTable('tasks', { id: int().primaryKey().autoincrement(), ... other columns ... categoryId: int("cat_id").notNull().references(() => WorklogCategory.id), .. other columns......

Drizzle Studio bug report with error context, local libsql.

installed libsql locally, created the db with "pnpm drizzle-kit push" which worked without problems. "drizzle-kit": "^0.30.5", "drizzle-orm": "^0.41.0", "@libsql/client": "^0.15.0", attached is the bug report with the error context.....

Using prisma to select columns not returning what I'm passing

I'm not sure what is happening. I'm in the process of switching to Drizzle from Prisma and am having an issue with my query that is causing the select object I'm passing to not be respected and just returning the columns for one of my tables. I have this query trying to select some specific columns from each of my tables ```javascript db.$drizzle .select({...

joins overwrite select?

Am I crazy or this is not supposed to happen? My schema is: ```js...

Introspect on a Supabase project -> non existing `userInAuth` relation

I'm trying to run drizzle-kit introspect on an extremely simple project, with little more than user authentication. Everything seems to work fine, but the generated relations.ts tries to import and use userInAuth from the generated schema.ts But that it's not exported ( or created ) in schema.ts. I believe that has something to do with Supabase having an auth schema, that has a relation with the users table I'm using on the public schema. But, how I'm supposed to manage this structure with Drizzle? ...

drizzle-zod insert/update schema refinements type

I usually want to apply same refinements to insert and update. To avoid duplication I want to define them in an object. How can I type it properly so that it knows the type of the schema arguments, etc.? ```ts type TableRefinements = ... ...

Double Slash in Path Causes ENOENT Error When Running Migrations in Docker

Hi everyone, I’m encountering an issue with Drizzle Kit when running migrations in a Docker container. The error occurs because Drizzle Kit is trying to read the 0000_snapshot.json file using a path with a double slash (//), like this: ENOENT: no such file or directory, open './/app/apps/my-app/src/drizzle/meta/0000_snapshot.json' The file exists at the correct path (/app/apps/my-app/src/drizzle/meta/0000_snapshot.json), but the double slash seems to be causing the issue. Here’s what I’ve tried so far: ...

do I still need to use drizzle-kit?

I"m not doing any migrations or generation. Just doing selects, inserts, and updates into existing tables. I have most everything working and didn't instal drizzle-kit. But not sure how to do relations so not sure if drizzle-kit plays a part there?

update many to many relationship

I'm working with Drizzle ORM and have a many-to-many relationship between projects and users using a projectUsers join table. When updating a project's members, I see two possible approaches: 1- Delete all existing members and reinsert the new ones 2-Selectively update the members...

TypeScript Error: Circular Reference in Drizzle ORM Schema

Hey everyone, I’m getting TypeScript errors in my Drizzle ORM schema due to a circular reference. Here’s the code: typescript Copy Hey everyone, I’m getting TypeScript errors in my Drizzle ORM schema due to a circular reference. Here’s the code:...

rewrite with db.query

hello there... how can i write it with db.query, as this is chatgpt generated code and it gives me desired results but i want to write it with db.query ```ts export const getPublicNavbarCategories = () => { return db...