Drizzle Team

DT

Drizzle Team

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

Join

ER_TABLE_EXISTS_ERROR

Can someone explain me what is the proper workflow? 1. change schema.ts (add another column to table) 2. generate migration 3. migrate...

column "summary" cannot be cast automatically to type jsonb

Hello! I'm getting this error when running my migrations, I used to have a text field and now it's a jsonb ```ts...

how to use in deno

im trying to use it in deno but there are errors
No description

Postgres timestamp that will be the same across regions

Hello everyone, So I have a statement like the following: ```sql...

is there a way to wrap a column select with ST_AsText or any other sql statement?

I've created a custom column type but the column return by default a binary data, instead i want to wrap the select automatically with ST_AsText to human readable text.

inferring the column information from the imported schema

is there anyway to get the column information from the imported schema information. When I dump the schema I can see that there is [Symbol(drizzle:Columns] property but not sure how I'd access it. Does drizzle provide some sort of API for extracting this data?

Drizzle tries to import mysql2/promise even though I want to use postgress.

I got: node_modules/drizzle-orm/mysql-core/db.d.ts:1:38 - error TS2307: Cannot find module 'mysql2/promise' or its corresponding type declarations. 1 import type { ResultSetHeader } from 'mysql2/promise';...

Filter for articles with at least one comment

I am trying to migrate to Drizzle from Prisma and I am having issue with being able to query for all Articles that has at least one Comment as the title says. Here's a simplified version of my schema: ```typescript export const articles = sqliteTable("Articles", {...

How to get a similar result of db.query but with extra aggregation and using select

I have the following drizzle query which works correctly but the results is not what I expect since we are grouping votes as well by their ids. ```js export const mostUpvoted = await db .select({ id: feedback.id,...

Next 13, Next-Auth with Neon Postgres and Drizzle vs Prisma 5

I am trying to set up Next-Auth with Neon Postgres and Drizzle, but failing miserably. I set up a repo with several branches, including configurations for: 1) Next 13, Next-Auth, Neon Postgres, Prisma 5...

error: column "x" is in a primary key

I'm getting the following error, when trying to push my schema to my remote db: error: column "x" is in a primary key The weird thing is that everything works fine, when I drop all tables and run it for the first time, but if I try to re-run drizzle-kit push:pg, this is the error I get, even if the schema has not changed at all. Does anyone know what might cause this?...

postgres error: type "serial" does not exist

I want to migrate my my changes but i get this error: type "serial" does not exist. This is my schema: ```ts...

planetscale cache error

not sure if the issue is from drizzle or trpc, but trying to query the db via the RSC api fails with this error ```log result: { data: { secret: null,...

MySql 8 - How to use onDuplicateKeyUpdate with array?

as the title says, how do i use onDuplicateKeyUpdate with arrays? I can pass an array to .values() function but after that i have no idea how to handle duplicate. Help would be appriciated. thanks

Postgres json_agg

How can I create this equivalent using drizzle? ```sql select p.id,...

Performance difference between `.select()` and `.findMany()`

Is there any performance difference between .select() and .findMany() when using in prepared statements? Or any benefit of using one over the other? Which one is preferred in prepared statements?...

"VALUES(Column)" abstraction ( quick )

So, using MySql, I can use [insert query here].onDuplicateKeyUpdate({ set: { name: sql'VALUES(name)'}}). I was wondering though, if there's any abstraction for the VALUES function. On the site: https://orm.drizzle.team/docs/insert#on-duplicate-key-update, it only shows example to set an fixed value or the one that was already set - emulating "do nothing behaviour" - is there any abstraction for that SQL function?...

Prepared statement returns undefined

I have the following server action: ``` export async function getUserByEmailAction(email: string) { return await psGetUserByEmail.execute({ email })...

Prepared Update statements

Is it possible to use preparad statements for updating data? I was able to use prepared statements with .select(), .findFirst(), or .findMany(), but I am having trouble with .update(). If possible, what would the syntax be? I am trying to update a verificationToken, and I would need two placeholders there. Tried something like this, but It's wrong: ```export const psUpdateEmailVerificationToken = db.update(users).set({...

Schema to type

Hey guys, how do you make a schema item as a static type ? for example, this thing: ```ts export const orderItems = pgTable("orderItem", {...