Drizzle Team

DT

Drizzle Team

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

Join

HELP: Key columns "resource_id" and "id" are of incompatible types: text and integer.

I don't know what to do anymore i've tried all the possible solutions i could think about, `export const bookmarks = pgTable("bookmarks", { id: serial("id").primaryKey(), user_id: text("user_id")...

Docs unclear on connection pool vs. direct connection

In the docs under "Supabase" it teaches you how to setup Drizzle w/ supabase. The last part shows how to set up the connection: ```ts import { drizzle } from 'drizzle-orm/postgres-js' import postgres from 'postgres' import { users } from './schema'...

Serializable isolation level - for update selects

Hi, Is there a way to add "for update" to the end of the query to help with serializable transactions? Without it, we cannot read then later update the same record in a transaction in postgres. So far, I've just written out the sql myself and lose most of the types....

Json object aggregate

In a multilingual app, I am using relational queries (but I could also just work with normal selects) to retrieve rows and their related translation strings. My schema has a bunch of tables like so: ```ts export const projects = pgTable('projects', { id: nanoid('id').default(generateNanoid()).primaryKey(), createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),...

many to many self reference

I'm trying to define "follows" & "followers" relations on a user entity. Obviously this is a many to many relation, but how to I define both "edges" in my relation? ```typescript const userToUsers = table("users", { userId: text(),...

Extract a type from a table

Imagine we have a user table like ```ts export const user = pgTable( "user", {...

Best practice on running migrations

I have a serverless framework setup and during my testing I've been using the db push but now that I have something setup to actually test my migrations I'd like to run:
await migrate(db, { migrationsFolder: "drizzle" });
await migrate(db, { migrationsFolder: "drizzle" });
whats the best path to actually running this from an npm script or from a ci for example. Or even locally without using push. Basically, I've generated my sql migrations but I now need to run them....

Initial query after Neon's suspend_compute

Experiencing problem for the first query when Neon is starting up

I have some enum types on a schema, but I can't define it in drizzle-orm.

I have defined a couple of enums in another schema, let's say main. Now I want to define it in drizzle-orm, there's the pgEnum but if I use it, when creating migrations or pushing to the database it'll try to change the table column types from main.enum_name to enum_name which fails. It'll be great if we had something similar to the schema.table but for enums (schema.enum)....

Unexpected identifier 'TABLE'

I used drizzle-kit generate:pg to generate this schema ```sql CREATE TABLE IF NOT EXISTS users ( user_id INT PRIMARY KEY, username VARCHAR(255),...

How to join tables from different dbs in same db cluster?

Hi is there the possibility to join tables from different schemas? We have a mariadb cluster with different schemas and would like to join tables from different schemas. Is that already possible with drizzle?...

Why is my query so much slower when filter by all four latitude/longitude bounds than just three?

When I uncomment out any of the latitude / longitude filters, the response latency spikes from ~50ms to 2000ms. (a similar query on prisma runs in just ~60ms, even with all filters.). Does anyone have an idea why? Or how I could fix this? Unfortunately, migrating to PostGIS is not an option at the moment ```typescript const facilities = await db.query.facility.findMany({ orderBy: desc(facility.internalRating), limit: 1,...

Enum type gets lost

Setup: I have a server-side db schema definition which I push with bunx drizzle-kit push:sqlite and pull on the website with bunx drizzle-kit introspect:sqlite in my schema definition I have the following table ```ts...

Hey I looking for the documentation of the `get()` methods

I ran into this code https://github.com/nextauthjs/next-auth/blob/main/packages/adapter-drizzle/src/lib/sqlite.ts#L105 where they are using get() a lot. I could find the documentation for it? anyone as any idea what it does or how to use it?...

No query result types

When i'm doing this.conn.query.organizations.findMany({}) there is no autocomplete for organizations columns, it shows only relations (restaurants) this.conn is PostgresJsDatabase<typeof schema> But if i specify ```...
No description

Help migrating raw query from prisma to drizzle

Trying to get the below query which has multiple joins into drizzle. It's one of the last ones I have and I am not sure if I should go the route of query or select. Query didnt have or show any docs on joins. Whats the optimal way to do this and is it possible to do also the count in the same query or will that still have to be an extra or separate? `` const results: any = await prisma.$queryRaw...

Dropping mysql unique errors

Hello! I saw there were already an issue created for it https://github.com/drizzle-team/drizzle-orm/issues/998 database: mysql...

drizzle-zod object scoped refine

I would like to check an objects multiple columns. For example whether password field is equal to confirmPassword filed. With zod it was a .refine() after a z.object(), but I cant get it work with createInsertSchema() Is there any workaround to work with react hook forms?...

connection ECONNREFUSED when trying to push to neon db

Hi people, I'm trying to connect my next.js app with drizzle to neon db, but I'm getting this error when i run push:pg ```bash...

Setting connectionString from env in sveltekit

I've been trying to get my connection string from .env into the drizzle.config.ts file, but vite aliases are not working within the file, so i cannot access the aliased sveltekit env variables. I really don't want to export the variable as VITE_ since that could be a security risk in the future....