Drizzle Team

DT

Drizzle Team

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

Join

Drizzle with Next 13.4.2 & Vercel Postgres Timeout

Hi all. I'm trying out NextJS server actions and Drizzle for the first time. I have it hooked up to Vercel Postgres as the docs describe and all seems to work....

I think I don't really understand migrations local sqlite.

It's a local sqlite db (DB_URL=file:dev.db) in a nextjs & trpc setup. I'm trying drizzle for the first time & I did follow the steps mentioned https://github.com/drizzle-team/drizzle-orm/blob/main/drizzle-orm/src/sqlite-core/README.md#-quick-start. I ran npx drizzle-kit generate:sqlite & it succesfully generated a migration. Good Job Drizzle! The problem is how do I push these migrations to my dev.db file? Do I need to push them manually? Am I missing something? I was planning to later use Turso & switch to it but even in the case of turso, I think I would have to manually write each migration in the db shell. Drizzle Kit does not have a push command for sqlite. I'm using drizzle-kit: v0.17.6 drizzle-orm: v0.25.4. Any help is appreciated as I'm tired reading docs & searching for similar issues here....

Connecting to Vercel Postgres

I'm trying to connect to Vercel Postgres like this: ```ts import { drizzle } from "drizzle-orm/vercel-postgres"; import { sql } from "@vercel/postgres"; ...

insertID not returned correctly when using custom UUID

``export const users = mysqlTable("users", { id: varchar("id", { length: 36 }) .primaryKey() .default(sql(uuid())`) .notNull(),...

weird ilike postgres behavior

hi, I have a very weird issue when trying to filter using ilike in postgres, both my local instance which is running in docker and fly.io postgres, which suggests this is a drizzle issue, here is the schema of my table: ```typescript export const points = pgTable("points", { ...defaultCols,...

Cannot make a .all() query on an empty table (Bun SQLITE)

I am new to SQLITE but i'm unable to make a .all() query on an empty table in a Bun with Drizzle project using a local database file. Is this normal ? There may be an obvious reason to why this is happening but I have this error : TypeError: null is not an object (evaluating 'this.values(s).map')

Self referencing nullable ID field not assigneable in a `eq` statement

I am not sure if I encountered another edge case but basically I have a self-referencing table where the reference can be nullable ```typescript export const carrierTasks = pgTable('carrier_tasks', { id: uuid('id').primaryKey().defaultRandom(),...

Custom `Select` object returns type `any`

Databases like Planetscale do not support FK constraints. As I understand I can manipulate the returned data structure from within the select clause. The data structure returned is correct but there is a typescript error casting it to any. Is there a way to fix this or am I misusing select? ```ts...

schema generates wrong index

I have this schema: ```js export const historyFiles = pgTable('history_files', {...

MySQL (Planetscale): Cannot read properties of undefined (reading 'name')

Hi Hopefully someone can help me. I'm getting the above error in my insert query. ```ts...

Deploying Next.js w/ Drizzle on Vercel with Turborepo

I have a turborepo with Next.js using drizzle-orm as a shared package. A bit of context - I'm using a monorepo with drizzle and share the tables, types and schemas across all my apps by having a shared packages/database library - that my Next.js app is consuming. One issue I've had is that in order to get drizzle-orm working in my monorepo I've had to install it globally ie. in my root level package.json. ...

uuid missing in drizzle-orm/mysql-core?

There is a uuid method in the drizzle-orm/pg-core package, but none in the mysql-core package. What is the reason behind this? What should we use instead to generate uuids automatically?

DatabaseError: Duplicate column name 'id'

hey guys, i have a problem in my query but cannot figure out what is causing it. ```ts const coursesSq = db .select({...

numeric returns string when querying with Postgres

``` export const order = pgTable( 'orders', { ... totalValue: numeric('total_value', { precision: 10, scale: 2 }),...

Need help transform a nested prisma query to drizzle

Hey I'm trying to translate the following prisma query to drizzle: ```ts const invite = await prisma.invite.findUnique({ where: {...

Type error for eq()

I get Expected 1 arguments, but got 2. in a statement like this:
.where(and(eq(menu.id, form.data.id)), eq(menu.userId, session.userId));
.where(and(eq(menu.id, form.data.id)), eq(menu.userId, session.userId));
...

InArray Function not Working

Why is the drizzle Function inArray mapping my array from ['1ed01d30-d16d-4b8f-b5d0-01b2a5d94d13', '37fdf74f-4069-4eab-8eee-5ad282c66667'] to (('1ed01d30-d16d-4b8f-b5d0-01b2a5d94d13', '37fdf74f-4069-4eab-8eee-5ad282c66667')) the Double brackets are messing everything up what is goin on

Raw sql nullable types, sql<Type | undefined>

const result = await db.select({
customField: sql<Type | null>`...`
const result = await db.select({
customField: sql<Type | null>`...`
...

Using with NestJS and Zod

I'm trying to use drizzle-zod and nestjs-zod together to create Zod schemas and classes for insert and select. I mostly got it to work, even with Swagger! However, I'm running into a problem with one of the create schemas. My table is defined: ```ts export const addresses = pgTable('addresses', { id: uuid('id').defaultRandom().primaryKey(),...