Drizzle Team

DT

Drizzle Team

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

Join

sql.raw() does not get columns from Table object

``typescript sql.raw(date_format(${MyTable.mycolumn}, "%d-%m-%Y") like "%${search}%") // This errors sql.raw(date_format(${MyTable.mycolumn.name}, "%d-%m-%Y") like "%${search}%"`) // This Works! ...

UPSERT operation not working for SQLite/Turso

Hey! So I'm trying to do a BULK UPSERT for multiple rows with a .returning() and its not working. I expect: - UPDATE: rows which include the PKs "id" - INSERT: rows which DO NOT include the PKs "id" the code is as follows (I've followed the docs and tried some variants): ```ts...

Difference between dialect and driver

I have a question, when I started using drizzle, to configure a database it was enough to declare the database in the driver parameter, but now the configuration also has a driver dialect, what is the difference between the two?

equivalent of a sql query in posgresql

help me i dont understand how to make subquery in posgresql ```SELECT products.product_name, products.units_in_stock FROM products WHERE products.units_in_stock = ( SELECT max(products.units_in_stock)...

Unable to setup supabase with drizzle

Using this https://orm.drizzle.team/learn/tutorials/drizzle-with-supabase#setup-supabase-and-drizzle-orm to setup supabase but always getting errors on migration and studio scripts. I'm using pnpm and have setup my .env.local variables. Drizzle version:
drizzle-kit: v0.21.2
drizzle-orm: v0.30.10
drizzle-kit: v0.21.2
drizzle-orm: v0.30.10
...

I made a change, yet generate says "No schema changes, nothing to migrate"

i added a column to a table balance: integer("balance") and drizzle-kit generate:pg generated the correct migration:...

How to use libsql features in migrations

Hey there, first time using sqlite here, AFAIK, you can't modify a sqlite column to, for instance, change its ON DELETE action from nothing to cascade. However, libsql mentions this in its docs https://github.com/tursodatabase/libsql/blob/main/libsql-sqlite3/doc/libsql_extensions.md#altering-columns which makes me think there is actually a way to do this without using a mirror table. I understand that running 'drizzle-kit generate' with schema changes like this one will output a warning saying you should write the migration yourself. What I don't understand is where should I do this. Should I edit my 0001_etc.sql file and write my code there? If i do that, and write something like libsql> ALTER TABLE emails ALTER COLUMN user_id TO user_id INT then I get an error because libsql> is not recognized, but then what is the point of writing driver: "turso" in my config file? isn't the turso driver what tells drizzle it can use libSQL features?...

Get raw SQL string with parameters

I use drizzle to build up SQL strings - but I need to get the final SQL string. I can use query.toSQL() and then do a string-replace on ? with toSQL().sql | toSQL().params. My questions are: - is this the right way to do it?...

Rename conflicted column (postgres)

I am having a bit of trouble getting this to work. ```js await db .insert(schema.listings)...

(drizzle-kit) npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memo

npm add -D drizzle-kit npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful....

equivalent code drizzle

how to make the equivalent query in drizzle? ``` const validThreadMessages = await db .selectDistinctOn([threadMessage.threadId], {...

drizzle schema type error

hican any tell me whats wrong? i had mysqlite before and everything was working
No description

drizzle-kit push not updating table schem

``` import { sql } from "drizzle-orm"; import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; export const newsTable = sqliteTable("news", {...

[Eslint]Drizzle `.delete()`

Weird stuff. My Eslint for drizzle has a problem whenever i use .delete()....
No description

t3stack, multi-file schema, can't use with.

I am using a multi-file schema for my project and the tables are generated appropriately, and the relations are also good. but when trying to use db.query with a "with" inside the query, i am getting an error: Cannot read properties of undefined (reading 'referencedTable') When doing the same for a single-file schema it works. I suspect that it has to do with the configuration i am using but i cant figure it out. help is very appreachiated. Attached is a screenshot of where i believe is the error (because when importing * as schema from schema for the schema it works). also attached is my drizzle.config.ts...
No description

Two tables that references each other

How can I do two tables that references each other? I have provided a minimal example to showcase what I am trying to achieve. ``` const table_1 = pgTable('table_1', {...
No description

unsigned bigint casted to string

Hey y'all. So, I currently faced an issue with drizzle where I had a column of type unsigned bigint with a FK constraint. On querying the row the value returned is casted to string. I'd like to know what's the best way to fix the typing or this behaviour. Because TS still interprets the type as number however at runtime the value is casted to string and has caused serious bugs in our app

Migrations not changing on adding notNull

Is it intended behaviour for migrations not to detect and react to the addition of a .notNull on some column ? Currently, my use case is that have a first migration that has created the table, but now the second migraiton (adding the notNull) doesn't actually create a migration....

Is there a way to simulate mode: 'string' for bigint?

Have the fields type bigint in postgres and type string when querying/inserting/updating

drizzle-kit push inconsistent with database with migrations already applied

Hi team Just wanting to sanity check something here to make sure that I am not barking up the wrong tree...From my understanding, the drizzle-kit push command should look at changes that I have made and push these up to the database before I make a migration to commit that change for good? Anyway, here's my issue... So, I've got a pg_enum defined:...