Drizzle Team

DT

Drizzle Team

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

Join

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.

Plans to add array related support for Postgres?

+ features to append an object to an array field in postgres?

Migrating from Prisma

Hi, I have an existing project already in production built using prisma and postgres (supabase). I am planning to go serverless and hence planning to migrate to drizzle + PlanetScale. Here is how I am planning it: 1. Use Prisma to generate the entire schema structure in MySQL (Planetscale) 2. Use Drizzlekit to introspect and generate types. 3. Use Drizzle ORM for querying....

Cannot read properties of undefined (reading '0')

What is the expected behavior when using get() when there would be no matching results for a given select query? Does it return null or would this be an error? At present it's giving an error. I'm new to discord, but I guess I expected it to return a null. For example, the following query works and returns an empty array:
db.select().from(users).where(eq(users.email, email)).all();
db.select().from(users).where(eq(users.email, email)).all();
whereas changing all() to get() results in error trying to access first element of an empty array (drizzle-orm/utils.js:40:37):...