Drizzle Team

DT

Drizzle Team

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

Join

Migrations not working on github actions

Any suggestions to debug this on actions? Is it possible that the database is not created?

"The supplied SQL string contains more than one statement" after running "generate:sqlite"

I just updated one of my schemas with a few columns and now my project is broken. This is the generated SQL ``sql ALTER TABLE projects ADD project_id` integer;...

[bug] Some sql statement looks broken when bulk insert

```ts await db.insert(users) .values( { name: 'Andrew',...

Return first or throw

I have a hard time believing this hasn't been asked yet, but my search results have yet to yield anything. Is it not possible (or planned) to do something like: ```ts const firstItem = db.select().from(users).where(eq(users.id, userId)).takeFirstOrThrow()...

Can't find meta/_journal.json file when running migrate

Trying to run migrate() from a lambda function and I can't figure out why it's unable to find the _journal.json file. My structure is in the attached image. In db.ts, I'm calling this migrate function like so: ```ts...

Wrong type on decimals

Hello, I have encountered something interesting. The first screenshot shows what I'm inserting into the products table, second shows the schema of the products table and the third one shows what I get when I query the products table. As you can see all decimal fields are now strings but typescript is telling me that they're numbers.
No description

Check

Hello there, from this discussion: https://discord.com/channels/1043890932593987624/1090486363251544124/1093092996200796200 Is it the way to add check constraint? ```ts...

cascades

I know you can add .references() to set up foreign keys in a table definition, but how do you set up cascades?

jsonb field definition.

What's the right way to define a jsonb field? I have a type type MetaData = {keywords?: string[];} and a field meta: jsonb<MetaData>("meta"), but I'm getting the typescript warnings Type 'PgJsonbBuilderInitial<MetaData>' is not assignable to type 'AnyPgColumnBuilder'.ts(2322) on the lhs and Type 'MetaData' does not satisfy the constraint 'string'.ts(2344) on the rhs. Thanks in advance.

"Extend" tables by other tables

Hey all, first of all great work with drizzle. Haven't had the time to play around with it so far. But just from how I currently use other orms. I have an AbstractEntity "class" which isn't an actual db table, but shares the common column each table should have e.g. a unique id. Basically like a parent class, but for DB tables....

maximum call stack exceeded

Weird bug where whenever I add a where eq clause getting maximum call stack exceeded

Drizzle recommended way to migrate reset

Apologies if this is a stupid question, I just recently migrated out of prisma and into drizzle. One of our common use cases for the dev DB was to run yarn prisma migrate reset when we wanted to reset our DB. Is there a drizzle equivalent way to do that?...

compound uniqueIndex

In Prisma, I have in my schema definition the following declaration that requires userId and timestamp tuple to be unique:
@@unique([userId, time])
@@unique([userId, time])
...

planetscale: how to index col using drizzle?

Hi, seems most of the samples are pg. I'm using planetscale, and no having any luck figuring out how to index a col. here's simple table I'm wanting to use to test/eval: ``` import { varchar,...

[Bug?] Drizzle generates a broken query when passing an explicit value for a column as `undefined`

I've translated most of my logic from Prisma usage -> Drizzle. Noticed an issue where when explicitly passing attributes as undefined while inserting, drizzle generates a SQL query like:
sql .... SET exampleProperty = ,
sql .... SET exampleProperty = ,
which throws a syntax error during runtime...

Help improving my query

If feel like this is far from how what it actually should look like in drizzle could I get some pointers what I can improve

Left join with JSON

I'm using PlanetScale (MySQL) and have 2 tables: orders and products. Every order contains basic info about the ordered products (see screenshot). Is there a way to do this?: ```ts...

drizzle bug won't let me update mysql table

wrote a bug ticket on github describing the bug but just wanted to post here as well for visibility https://github.com/drizzle-team/drizzle-orm/issues/364 I think its because of reserved words in the table name...

Generated Collate value

Not sure if this is relevant but I'm translating a Prisma schema into drizzle. Every Prisma table had COLLATE utf8mb4_unicode_ci; added to the generated MySQL. One of my drizzle tables instead has COLLATE utf8mb4_0900_ai_ci; I'm not good enough at dbs/sql to know if this is important, a bug, or irrelevant...