Drizzle Team

DT

Drizzle Team

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

Join

Steps to fix errors like `drizzle/meta/0000_snapshot.json data is malformed`

I am not sure how I got into this state but it blocking any updates to my schema i made issue https://github.com/drizzle-team/drizzle-orm/issues/1554...
No description

Drizzle Studio: Failed to fetch tables from database

Hello! I am struggling to connect to Drizzle Studio with my local postgres database: Failed to fetch tables from database TypeError: Cannot convert undefined or null to object ...

I'm getting error when do db:push

Error goes away when i delete all tables. I'm working with planetscale.
No description

Is there a --force flag for drizzle-kit push?

Hey there! 👋 I'm having all sorts of problems when pushing changes to my database during prototyping. I end up deleting the SQLite DB and creating a new one. Is there a way to somehow force push the changes?...

Querying table based on a field of a related table

Hey everyone, I have no idea what im doing wrong, but the goal here is to get every subscription which its related plan, has the spaceId field according to an input. Here's what I got after reading the docs: const subscriptions = await ctx.db.query.subscriptions.findMany({ with: { plan: {...

insert returning relations

Hello, is it possible to have the relations included in the returned row using insert().returning()? Or do I have to make a separate query for that?

Where to get the types from?

I want to use the types of my schema parts. How can I include them? Thanks!!!...

Postgresql Join select columns with case

```ts const res = await db.select({ ...getTableColumns(table1), items: table2 }).from(table1).leftJoin(table2, eq(table1.id, table2.mainId))...

createInsertSchema & createSelectSchema difference

I am using drizzle-zod along with sveltekit-superforms and thoroughly enjoying the combo so far. One question I have is that what is the fundamental difference between the two functions above. I didn't find any related questions or documentation. I think they are mostly the same. taking in a drizzle schema and returning a zod object. Is it just a difference in semantics? I'll appreciate any input on this.

mysql on delete cascase

Seems like mysql with planetscale does not support "reference". Is there a way to on delete cascase or do I have to do it manually in a transaction?

Transaction doesn't support Promise.all

This works:
await db.transaction(async (tx) => {
await tx.insert...
await tx.insert...
});
await db.transaction(async (tx) => {
await tx.insert...
await tx.insert...
});
...

Drizzle with next auth user is undefined

Hey I am using next auth with dirzzle and my user is always undefined on the callback: What am I doing wrong? Or did I misunderstood something? ```tsx import { db } from "@/db"; import { DrizzleAdapter } from "@auth/drizzle-adapter";...

`push` column types conflicts for unchanged columns

I have added a new table to the schema. I have not modified anything else. I am getting this error (see image) when I run push:mysql. You can see that the column types are the same in reality. And none of the mentioned columns are from the table I am trying to create. ```text...
No description

CockroachDB Support?

Just wondering if anyone knows if Drizzle would work with CockroachDB? Looks like they both support the node-postgres driver so I thought I'd have pretty good luck but my migration failed, and as I was looking around I noticed on the GitHub readme that support for CockroachDB is ⏳ which made me think maybe I should wait. Any timeline for official support? Thanks for the help!

Drizzle error instance

Is there a Drizzle error type that i can use for my Fastify global error handler ?? What im looking for is maybe something like the prisma error type Prisma.PrismaClientKnownRequestError, And what i want is to identify the drizzle error so i can handle them properly. this is how my global error handler looks : ```javascript export default function globalErrorHandler(...

"Prepared statement already exists" error

I'm experiencing a problem with Drizzle ORM and Vercel’s Postgres (which I believe is Neon Postgres under the hood) in my SvelteKit application deployed on Vercel. Everything functioned perfectly until I tried to transition my request handling to edge functions using prepared statements. Here’s what I've implemented: 1. Defined a prepared statement in a separate file: ```export const getPublishedJokesPrep = db...

Malformed migration file

For some reason, when running migrations on the latest versions of drizzle-kit and drizzle-orm, it fails with data is malformed on most of my previous migrations' metadata: ```sh migrations/meta/0002_snapshot.json data is malformed migrations/meta/0003_snapshot.json data is malformed migrations/meta/0004_snapshot.json data is malformed...

using subquery with query builder

Hello 🙂 Please help me ) I try to use subquery with query builder, but i get a type error in eq function. How can i fix it?
No description

Multiple subquery on where condition in findMany

I wanted to know if how we could do a multiple subquery on the where condition on findMany. where: (campaign, { eq, and, exists, or }) => and( ...whereCondition,...

How to work with Cloudflare D1 on nextjs with drizzle - (Database Error: [TypeError: Cannot read pr)

src/lib/index.ts import { drizzle } from "drizzle-orm/d1"; import * as schema from "./schema"; const customConfig = {...