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 to declare PostgreSQL extensions/plugin?

Reference: https://www.prisma.io/docs/concepts/components/prisma-schema/postgresql-extensions Is there a way to declare postgresql plugin? Perhaps through the raw sql statement? Thanks in advance!...

How to consume existing supabase migration?

I have a supabase migrations and would like to reuse them as a starter for drizzle. When trying to point drizzle migration to the supabase's migration, it throws the error:
Error: Can't find meta/_journal.json file
Error: Can't find meta/_journal.json file
...

Prisma Studio style db explorer

Hey there! Anyone aware of a prisma studio style db-playground / db-admin-dashboard that works with drizzle? Would be super cool for developers and PMs alike ❤️...

Incorrect return type findFrist

Hi! I just upgraded to 26.0 and I'm refactoring queries to findFirst where needed. But the return type is not correctly inferred! The return type is just ```typescript...

Relations module - or condition

Hi there! I have a teams table, an users table, and a team_members table that connects these two. A team also has an ownerId column. Currently I have a query that fetches all the teams of an userId whether they are connected through the ownerId column or the join table....

Are foreign key polyfills for PlanetScale supported by Drizzle?

Hi Prisma supports this (although slow). See: https://www.prisma.io/docs/guides/database/planetscale#how-to-emulate-relations-in-prisma-client I want to use Planetscale but foreign key constraints are very important to me....

TS error: Argument of type PgTableWithColumns is not assignable to parameter of type AnyPgTable

Hi all, after updating to latest i'm getting this TS error. This is my db creation and schema. ``` import { User } from './schemas/user'; ...

Many-to-many relational query issues

schema, relations, statements: https://gist.github.com/kylewardnz/37104f989807e96555ea856294a2b670 1) executing the fetchArtistWithContent statement returns only the pivot table data on the members relation. This does make sense since it's actually a relation to that table, but logically I'm wanting the data from the members table. This can be done by changing the with statement to: ``` with: {...

drizzle-kit: push wants to change column type that hasn't changed

just updated my dependencies: ``` dependencies: - drizzle-orm 0.25.4 + drizzle-orm 0.26.0...

drizzle-kit doesn't seems picking up the default config TS (up:pg)

Hi I'd like to report that the latest drizzle-kit 0.18.0 doesn't seems to detect my drizzle.config.ts when running up:pg, it's kinda weird because my generate:pg execution is working.

Build queries dynamically with conditions.

How to build query on the basis of if-else conditions? I have tried doing it as below
let dbQuery = db.select().from(orders).where(and(eq(orders.organizationId, orgId), ne(orders.orderStatus , "CART"), eq(orders.id, Number(query))));
let dbQuery = db.select().from(orders).where(and(eq(orders.organizationId, orgId), ne(orders.orderStatus , "CART"), eq(orders.id, Number(query))));
```...

drizzle-kit: Error: Cannot find module 'drizzle-orm/version'

Hi there, when I run the following command: pnpx drizzle-kit generate:pg, I get the following error and I am not sure why: ``` drizzle-kit: v0.17.6 ...

Conditional logic within template strings not supported on raw MySQL query

I am trying to execute raw SQL query with some conditional logic but it always fails. It's working fine with mysql2 driver. ``js const [res] = await db.execute(sql SELECT ...

executing an `update` statement does not use `.onUpdateNow()` defined in schema

Hello everyone 🙂 I have the following schema for my USERS table: ```ts export const users = mysqlTable("USERS", {...

Help with raw query

The following query is all raw. Is there a way to make SQL raw only the part of the where clause? (or still better a way to not use raw sql at all) ``javascript await dbConn.execute<User>( sqlselect * from ${UserModel} where similarity("name", ${q}) > ${treshold}`...

Create GIN index in Postgres

I need to create this index in postgres:
CREATE INDEX users_name_gin_trgm_idx ON users USING gin (name gin_trgm_ops);
CREATE INDEX users_name_gin_trgm_idx ON users USING gin (name gin_trgm_ops);
...

How to plus 1 to the current value of a column when update

How to plus 1 to the current value of a column when updating a record

Ordering by a string column but coercing it to a number for ordering

I have a column that mostly contains numbers with only a very few exceptions and want to apply order by, but given the column is of type TEXT the ordering is of course 1, 10, 100, 101, ... Any suggestions how to coerce the column for ordering? Probably applying the sql tag with an ABS or so?...

type union on entire row

i can think of workarounds for this but figured i'd ask if i have a table that's like [id, type, data (json)] ...