Drizzle Team

DT

Drizzle Team

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

Join

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

drizzle-orm/mysql-core has no InferModel or MySqlRawQueryResult exports

Hi there, I'm not sure if I'm misunderstanding something here, but as per the documentation, drizzle-orm/mysql-core should have the exports InferModel and MySqlRawQueryResult, but whenever I try to import them in my project, I get the error Module '"drizzle-orm/mysql-core"' has no exported member 'InferModel'. I'm using drizzle-orm version 0.23.2, so it'd be awesome if someone could clarify whether this is a known issue, or what's happening here exactly.

SQLite migrations are not being applied

First time using SQLite and drizzleORM, so forgive me if this is a stupid question. I've been trying to set this up for an hour now. I have installed drizzleORM and drizzle-kit, I've added the setup from the docs and I have ran my first migration with drizzle-kit generate:sqlite. I have a db file in my root and folder with the migration that creates a users table. I get an error when I try query the users table, saying it does not exist....

Question: Wouldnt it make sense for value to be automatically notNull if you set a default

Right now you would need to use notNull().default(true), is there a reason for it be still nullable with just default?

Code generated value

I'm using SQLite. How can I create a custom type with an auto-generated value which is generated in code and not the database? I managed to get it to work, but I have to pass a blank value for the field whenever creating records otherwise I get a type error, and I'm having trouble finding the right combination of options. ```ts import {customType, sqliteTable } from "drizzle-orm/sqlite-core"; import { createId } from "@paralleldrive/cuid2";...

Randomly stopped being able to generate migrations (MySQL)

Hey! Been trying things out the past day and everything was going great - until I deleted my migrations folder, attempted to re-generate migrations, and was met with 0 tables 🤣 I've killed-off all of my schema, except for one simple table, and ran generate:mysql with DEBUG; ```bash...

BUG: Postgres migration script generates a few syntax errors

Context: I was running migrations with drizzle-kit's migration function from node-postgres , and kept getting a lot of errors. I had to make the following changes to the SQL script: 1. Add double quotes around table, index, and other field names 2. Array fields with default values just never generated the right code. So I had to manually add the default value in. ...

uuid's being inferred as strings

When I use InferModel on a table that has a uuid type, I see that the column gets inferred as a string instead of as a uuid type. Seems like the migrations are correctly using the native postgres uuid type, so confused why it's not being returned as a UUID

Any easy way to create a typescript ENUM type from pgEnum?

Prisma used to auto-gen all the enum types as well which are heavily used in our application.