Drizzle Team

DT

Drizzle Team

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

Join

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...

Can I know when I can use Mysql proxy driver?

Hi, I’m Daun and I’m a huge fan of drizzle. i’m really grateful that drizzle is open source and have this wonderful community. Im just curious if I can know when can I use Mysql proxy driver. It’s okay if it takes long or hard to estimate but it’ll definitely help us to make far better technical stack decision (This specific feature is very essential to us at the moment)...

Mocking database

I want to mock the PostgreSQL database and access it with Drizzle ORM. I tried to write a TypeScript class that should work the same way as pg's Pool class, but instead of hitting an actual database, returns rows from an in-memory object. However when SELECT'ing from the table I had mocked, Drizzle returned an object with all keys having undefined values. Any help? 🙂 ```typescript...

What does MySQL bigint config mode do?

In a mysql schema, when creating a bigint, it wants a config object with a mode key where mode could be number. What does this do?...

MySQL unique constraint

In the drizzle schema, is there a way to label a column with unique constraint in mysql? I'm only seeing uniqueIndex

Error querying planetscale db

Trying to get setup with drizzle and running into this error. There's not much info here so I'm not sure how to debug it ``` TypeError: fetch failed at fetch (/home/kelby/work/jobs_fe/node_modules/undici/index.js:113:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)...

db push connection error

getting the following error on my first db push attempt ``` Ignoring invalid configuration option passed to Connection: sslaccept. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection /home/kelby/work/jobs_fe/node_modules/drizzle-kit/index.js:43680 const createConnectionErr = new Error();...

Select exists

Hi there, I was wondering if there is currently a good way of performing a ‘select exists’, to check whether a specific row exists. I could use the exists expression as a subquery, but this is not the same as the select exists if I only want to check if a record exists without returning the values....

Custom SQL function (json_agg & json_build_object)

Hello there. I'm new to Drizzle and I love it 😍. I have successfully made a jsonAgg helper....

Error migrating after updating to orm 0.23.3

After updating to the package released an hour ago, I am getting an error on migrating: error - RangeError: The supplied SQL string contains more than one statement at Database.prepare (.../node_modules/better-sqlite3/lib/methods/wrappers.js:5:21) at BetterSQLiteSession.prepareQuery (.../node_modules/drizzle-orm/better-sqlite3/session.js:19:34)...

workflow best practices with planetscale

So I’m building a small test app (drizzle looked amazing and will definitely want it in my main app project) with some tables for next auth and so on and I needed to ask; what’s the best approach when working with planetscale, I’ve read that for prisma it’s just db push however drizzle kit has migrations and a beta push as well, what would be the best move here? Of course trying to avoid destructive changes when pushing or updating the db schema...

Invalid default value for timestamp

Hi, I have recently started learning SQL and I've run into this problem with Drizzle Kit. I have this promoCodes table: ```ts // PlanetScale (MySQL) + Drizzle ORM export const promoCodes = mysqlTable( 'promo_codes',...