Drizzle Team

DT

Drizzle Team

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

Join

How can I extend queries with additional fields

I have the following model: ```export const titleEnum = pgEnum("title", ["Mr.", "Mrs.", "Ms.", "Miss.", "Dr."]); export const Client = pgTable("client", {...

drizzle-kit generate error

Hi guys, I'm using drizzle with expo sqlite. Everything worked fine so far but suddenly I cannot generate migration as drizzle-kit generate fails with the following error: ```
npx drizzle-kit generate
...

Json as a string

I currently have this schema: ```ts export const decks = mysqlTable("decks", { uuid: char("uuid", { length: 36 }).primaryKey(), name: varchar("name", { length: 25 }).notNull(),...

how to do unit test using drizzle ?

how to unit test this ? : ```import { eq } from 'drizzle-orm'; import { db } from '../db/connection'; import { usersTable } from '../db/schema';...

Drizzle wont connect to sqlite file on production?

``` /home/triz/apps/ftb-pack-tracker-discord/node_modules/libsql/index.js:93 this.db = databaseOpen(path, authToken, encryptionCipher, encryptionKey, timeout); ^ Error: ConnectionFailed("Unable to open connection to local database prod.db: 14")...

uuidv7

what's the best way to set a uuid-v7 column in Postgres using drizzle?

Drizzle running on Tanstack pages that don't even call the db,

After migrating from prisma to drizzle I was forced to import "server-only" in my db file: import "server-only"; import { drizzle } from "drizzle-orm/neon-http"; import * as schema from "./schema"; import * as relations from "./relations";...

Infered Zod Schema turns into Zod String

So I have this code, where I have a user shema. That user schema works and gives the correct type definitions. However, I also need a record with that user schema. For some reason, that user schema, which is supposed to be an object with various properties, is now infered as a zod string. How would I be able to create a schema where I have a string a a key and the user schema as a value?...
No description

Error creating migration in PayloadCMS

Not sure if this is the place to ask, but as Payload is just using Drizzle for DB Management and Migrations, I figured this might be a drizzle issue and not a payload issue. Anyways, when I try to create a new migration, I get the following error: ``` /node_modules/.pnpm/payload@3.45.0_graphql@16.11.0_typescript@5.7.2/node_modules/payload/src/bin/migrate.ts:100 throw new Error(Error creating migration: ${error})...

How to fix, issue while pushing the migration, drizzle is treating view as table and trying to drop

pgPush fails with “pg_stat_statements_info is not a table” error While applying the migration and pushing the migration using drizzle-kit push facing below issue, drizzle is trying to ...
No description

How to deploy drizzle studio with cloudflare tunnel?

I deployed drizzle studio on a server (EC2) and installed a cloudflare tunnel on it, but I couldn't proxy the drizzle studio web page like regular services.

Why drizzle-kit generates schema in invalid place?

My drizzle config looks like this
out: './drizzle',
schema: './src/lib/server/db/schema.ts',
out: './drizzle',
schema: './src/lib/server/db/schema.ts',
...

missing semicolon

I just generated migrations using drizzle-kit for my react native expo app and when attemping to run the migrations, there is an error: iOS Bundling failed 318ms node_modules/expo-router/entry.js (3071 modules) ERROR SyntaxError: /Users/<snip>/WebstormProjects/<snip>/drizzle/0000_hard_shocker.sql: Missing semicolon. (1:6) ...
No description

Comparing SQLite numeric with Decimal

Hello, quick beginner question: How am I supposed to compare an SQLite column with data type numeric with a decimal JS number? The numeric is read as a string, so shall I cast the decimal to string, like this https://github.com/drizzle-team/drizzle-orm/issues/570#issuecomment-1549158181 ? I guess that comparing decimal numbers as strings will not work properly ......

Better specs for my POSTGRES VPS?

I have a VPS which only purpose is to host a postgres server with two databases for the same product. I use Drizzle ORM in my apps and Drizzle Studio to connect to them, even though i use drizzle-kit v0.19.3 so i can host studio without connecting to drizzle.local.studio. My VPS is running on 2 CPUS and 4096 MB RAM. ...
No description

createInsertSchema fails to infer

Hello I've got: ```ts export const facts = pgTable( "facts",...

Drizzle Multi-Project Schema Issue

Setup: Monorepo with two packages sharing the same PostgreSQL database: - database package: manages main application tables - agents package: manages RAG-related tables with mastraalready prefix...

Detect when onConflictDoUpdate does a insert vs a update

Hi, I was wondering if there is anyway to know when a onConflictDoUpdate does a update vs a insert. Thanks!...

`db.$count` with extras throws error when correlating with outer table

Hi! I'm trying to use .extras() with db.query.orderTable.findMany() to get the count of related orderItemTable rows like this: ```ts const orders = await db.query.orderTable.findMany({ extras: (t) => ({ itemCount: db.$count(orderItemTable, eq(orderItemTable.orderId, t.id)),...