Drizzle Team

DT

Drizzle Team

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

Join

Database design

I'm building an app for a center 'school' for Quran teaching and memorization. I want to track students daily progress and attendees, there is also can monthly tests, each class also can choose best student of the week each week. My question is: how do I link these data to a certain year?...

How to mark migration as applied?

The title. I got a hybrid database-first and codebase-first migrations I do some changes on the database itself via db tools and later create a custom migration for those changes using drizzle. Now I need to mark it as applied. I'm struggling to figure out how to do that. I would really appreciate if anyone could help me out with this one...

visualizing schemas and relationships

is there good software i can use w/ drizzle orm which helps me visualize my schemas and relationships?

onedollarstats - invite feature

Hi, cool product! Is the "invite" feature not ready yet? I tried to invite a couple of persons and myself with another email and I don't get a link or something like that. I also send an email to [email protected] but it bounced back....

How to insert data into table (seed) every time I do a 'drizzle-kit push'?

How do you set that up? I can't find any documentation on that,

error while inserting the data in the dynamic table

Hi, I am trying to insert the data which is coming from the form into the table, so, I am using this ```tsx const tableName = data.tableName await db.insert(tableName).values() res.status(201).json({...

Drizzle forcefully dropping ENUMs

I am using a single neon db for 2 of my apps each app has 2 different ENUMs. If from scratch i push the first app it pushes alright But for the second app it asks for new enums creation an upon selection of create new the script tries to drop other enums and gets an error ```...

My database suddenly stopped working and there's no helpful error message

It was running just fine even 2 hours ago, nothing has changed on my end since then. Can't even access the database through drizzle studio locally, or even by going on Turso -> Edit Data -> Drizzle Studio. More serverside errors from the console: LibsqlError: SERVER_ERROR: Server returned HTTP status 401 ...
No description

drizzle-kit studio reading .env file

Heya, I just wondered if it's drizzle-kit that automatically reads the .env file? Is it possible to disable that? I'm reading my env files in via nextjs's @next/env library so I can make use of .local etc. But when drizzle-kit reads in the normal .env file next-env can't override the already read env vars with the .env.local since it thinks the already read vars are system wide env variables which always have the highest priority.. Any Idea how to solve this? Just a flag or something that disables automatically reading .env files would be perfect.....

drizzle-kit generate keeps trying to recreate enum value that already exists

I recently created a migration using drizzle-kit generate after replacing a pg enum value. the generated migration was incorrect as it added the new value but never removed the old one. Hence, I manually edited the migration to look like this: ALTER TYPE job_status RENAME VALUE 'completed' TO 'successful'; however, now whenever I run generate for subsequent migrations, it keeps trying to create the new enum value: ALTER TYPE "job_status" ADD VALUE 'successful';--> statement-breakpoint...

Nullable field cannot be inserted or updated

Hi! I've already broken my head, I've asked several ai chats why this might be an error, but they don't know why the error occurs The problem is that I can't create/update the channels record's userId fields when the userId isn't set to .notNull() When I bet .notNull() everything works for me, but I need the user Id to be an optional field...
No description

drizzle-orm/libsql 'file:' does not work with Next.js

I'm following https://orm.drizzle.team/docs/get-started-sqlite, but using e.g. drizzle('file:libsql.db') does not work with Next.js. When using import { drizzle } from 'drizzle-orm/libsql', I get LibsqlError: URL_SCHEME_NOT_SUPPORTED: The client that uses Web standard APIs supports only "libsql:", "wss:", "ws:", "https:" and "http:" URLs, got "file:". For more information, please read https://github.com/libsql/libsql-client-ts#supported-urls. When using import { drizzle } from 'drizzle-orm/libsql/node', I get Error: Neon: unsupported system: undefined. Both work fine when running a file via e.g. tsx but not when running with next dev --turbopack....

What is the recommended way to have a staging and a production environment?

For the record, I'm using Cloudflare D1. I know how to set up the wrangler.json file such that based on the environment I use a different database (same binding, just different database IDs). How can I make it so the drizzle.config.ts file uses a different .env file based on the environment being used?

password authentication failed for user "postgres"

``` <-- POST /api/checkout/create-checkout-session Query: select "id", "privy_did", "created_at" from "users" where "users"."privy_did" = $1 limit $2 -- params: ["did:privy:cm4wfnsso004pw1dbh5n8ns4c", 1] Error in getOrCreateUser: 40 | res = resolve 41 | rej = reject...

Find which migration is erroring when using the programmatic `migrate` function

I'm trying out PGLite for tests, where we use regular PG in production. I'm tracking down a error: cannot insert multiple commands into a prepared statement error, I assume there's an issue in one of the migrations. How can I find which migration specifically it's erroring on?

Zod validation errors when moving from drizzle-kit 0.20.14 to 0.30.2

I'm working on updating the version of Drizzle we use. I've run drizzle-kit up and it updated all of the snapshot files, however I'm still getting validation errors when running the generate command to generate new migrations. It seems that every enum field is showing similar errors (there are hundreds). Here's an example from the array: ```JSON {...

How to handle initial undefined state

Hey guys! I need some help on something that is probably trivial to a lot of you. I am using the useLiveQuery hook to get and then display data on a screen in my app (it's a todo app and i'm essentially getting the list data to be able to display) . The problem is that whenever I want to access said data, I ALWAYS have to use the optional selector to handle the initial undefined state. So my code is FILLED with a whole bunch of ? marks... How do you guys avoid having to do this?? I've used React Query before and the nice thing with them is that their useQuery hook returns a loading state that I can use to handle the initial undefined state of data and then display it, but I don't have that kind of feature with Drizzle....

Constraint does not exist when running migration

This is happening because one of my tables was looking like this: ```ts export const profiles = pgTable('profiles', { userId: uuid('user_id').references(() => users.id, { onDelete: 'cascade' }); ... rest of the columns...

Docker build error with sveltekit

Hello everyone, whenever I try to docker build my sveltekit app that uses drizzle I get the following error: ``` 0.187 > vite build
0.187 ...