Drizzle Team

DT

Drizzle Team

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

Join

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)] ...

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')