Drizzle Team

DT

Drizzle Team

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

Join

Passing SQL functions to insert

Is there any way to pass a SQL function like gen_random_uuid() to the insert function, for a specific (non-primary ID) column? Something like concat('foo_', gen_random_uuid()) for example.

Drizzle-kit database push connection error

When trying to run drizzle-kit push:mysql to push my schema to Planetscale, I get the following error. Am I missing something? ```sh drizzle-kit push:mysql...

Typescript error when importing the planetscale-drizzle db instance.

my db is hosted on planetscale and im trying to do the setup as explained in the drizzle docs but when I import db instance i get the following error. My code ```js import * as schema from './migrations/schema';...

Mapped column name and relation with the original name

Hi, I am taking over an old project and have found an issue, I'm not sure if I should file it as a bug: I have two MySql tables here is the oversimplified version: ``` events - id...

How to properly do foreign keys in schema with PlanetScale?

I'm aware that foreign key constrains aren't supported, but foreign keys themselves are. push: ```json sqlMessage: 'VT10001: foreign key constraints are not allowed'...

Typescript path alias not working properly

I'm new to Drizzle, but I'm not able to use the path alias on schema files. Using absolute paths on the imports works without a problem, but when using any @/... path everything breaks. Right now I'm working around this problema by denying @/ imports wit ESLint but that is not a good solution long term....
No description

Expand query from ID using .select()

Hi! I am trying to get the first name of a comment author, but only store the ID so the user can change their name. Here's my schema.ts ```typescript import { InferModel, relations } from "drizzle-orm"; import { pgTable, text, varchar, bigint, json } from "drizzle-orm/pg-core";...

PGEnum -> Typescript Enum

Hey there. Is there any convenient way people have found to conveniently turn a pgEnum into a typescript enum such as below? Currently I'm creating DTO's but i figured coupling them would be much easier :). I figure ZOD might come into play but we are utilizing NestJS w/ class-validator atm. ``` const typeEnum = pgEnum('type', [ 'short_text',...

Is Drizzle Kit/Drizzle Studio possible with RDS Data API?

I'm able to create the RDSDataClient for querying my DB using Drizzle ORM, but I don't see a way to use Drizzle Kit for DB inspection/push or Drizzle Studio for data exploration. The drizzle.config.ts seems to only make it possible to use the DB connection URI/params. Is there a way to still have these interactions with my RDS db if I'm using the Data API?...

How to apply migrations on postgres in a serverless enviroment?

Hello, I want to apply postgres migrations to my vercel DB. I see that the push command does not work for postgres and am therefore attempting to use the migrate function like so: ```ts...

Error when trying to generate a migration schema

anyone any ideas to what the problem is? It was working fine yesterday and now it throws an error when I am trying to generate a migration file. I was updating the relationships/adding a new table and when I tried generate a migration file, this error appeared this is the script i'm running "generate": "cross-env NODE_ENV=development drizzle-kit generate:pg --config=drizzle.config.ts", ...

Modelling self relations

I have a table categories with a parent fields: ``` { id: text("id").notNull().primaryKey(), .... ...

Issue running migrations to DB

I am having an issue running migrations to Neon. I checked that everything is exporting const variables and tried add the cjs version of drizzle kit and reinstalling node modules.. but no luck fixing it I also tried to run a migration on a new db and its still giving me the same error. not sure whats going on ```ts...

It is possible to have prepared statements inside transactions?

Is there a way to insert prepared queries inside a transaction ?

type config findMany or findFirst

Hi, I've one question i don't find the way to type correctly findMany() Like: export async function findAll({...

Any idea on how to pass a pool from postgres-pool to drizzle?

Passing a single client works, but for better connection management it would help to be able to pass the pool.

How to get another linked tables count?

I am new to Drizzle ORM and I wanted to get another tables data in my api. This is my api ```ts import { eq } from "drizzle-orm";...

I created a next auth adapter for postgres-js

The open PR was not working for me so I created a new adapter. I added it to a starter project so people can take it. This is temporary until we get an official plugin. I WILL NOT provide any support for this or maintain this repo https://github.com/c-karaolis/drizzle-next-auth-adapter-postgres

.prepare() in Next.js App Router

Hello! I'm trying to use PostgresQL prepared statement in the Next.js App Router and I have been getting stuck on "prepared statement already exists" Does anyone have an example I can refer to? It'd be a lot of help!...

Deleting records w/ sqlite-core.

Hello all, hoping to find some clarity/direction. So I'm trying to delete a record using; ```ts export async function acceptUserMail(mailItem: string) { return db.delete(mailbox).where(eq(mailbox.id, mailItem)).run(); }...