Drizzle Team

DT

Drizzle Team

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

Join

Infer insert model for select in "Insert into ... select"

Thanks for adding support for "Insert into … select". This is going to make FKs to internal IDs a lot less painful. I have plenty of use cases where all service interfaces work off external IDs (id) but to insert/update they will need to be mapped to internal IDs (iid). Here's a typical example where customer's external ID is resovled to its internal ID so it can be used in the relevant column of transaction table. ```ts...

On delete cascade not working

I have the following tables: ``js export const exercises = sqliteTable("exercises", { id: integer("id").primaryKey().notNull(), created_at: integer("created_at").default(sql(strftime('%Y-%m-%d', 'now'))`),...

Ignore unrelated indices

How do I make sure that drizzle doesn't delete some indices that I made separately? To be more specific, I created full text search indices using ParadeDB, which uses pg_search. Every time I do drizzlekit push, it deletes those indices and I have to recreate them. Is there a way to let drizzle know to ignore indices and tables/views based on some rule?...

Materialized views syntax error

There's a bug I've spotted where the query engine generates paranthesis () around the select query which gives syntax error when it is run. I cannot disclose the code but it had the following structure: ```typescript...
No description

libsql not generating migration for generatedAlwaysAs

No migration were detected by the drizle when I changed from this ```ts buildDate: integer("created", { mode: "timestamp" }) .notNull()...

Quick question

For those who used supabase as a db for drizzle did you guys disabled RLS or enabled RLS? I want to know more about it for those who've tried it out since I'm going to use this as a db

Brand ids?

Hi, it's possible to mapped a primary key to a branded type from effect? ```typescript export type UserId = string & Brand.Brand<"UserId"> export const UserId = Brand.nominal<UserId>()...

Problem with relational drizzle ORM

Hello, I create generic function and the problem is with relation Origin of my post: https://github.com/drizzle-team/drizzle-orm/discussions/3570...

`TypeError: Cannot read properties of undefined (reading 'query')`

```import "dotenv/config"; import * as schema from "./schema.js"; import { drizzle } from "drizzle-orm/node-postgres"; const db = drizzle(process.env.DATABASE_URL!, {...

Bug - snake_case and views

views don't obey snake_case ... firstName: t.varchar({ length: 256 }), lastName: t.varchar({ length: 256 }),...

Possible bug?

type UserID = number; type Data = { foo: string, bar: number, face: boolean,...

Insert row, on conflict do nothing, and "return the conflicted row if it exists" - in 1 query?

Is it possible to do this query in one single Drizzle ORM query? Cus currently .onConflictDoNothing() is always returning an empty array for me (which I'm guessing is by design unless there's something else I could do) My best solution is probably using multiple ORM calls in a transaction for now, but was wondering if there was a way of doing this efficiently that I don't know about My query:...

How to delete multiple db entries at once?

I have a list of IDs of items I wish to delete, but I cannot figure out a way to delete them. I would prefer not to use hard-coded SQL as that's why I chose to use Drizzle over other alternatives. Here is what I have and what I found, but does not appear to work. I could not find any IN function built into Drizzle. Any help would be much appreciated. ```ts // tagTable: my defined DB table schema // tagsToRemove: a list of Tags...

pull is creating wrong schema file

i have a schema with a user table and a settings table. the settings table has a foreign key on the user.id which is TEXT it creates a schema where the foreign key is set to INT it always wants to recreate the settings table, but this is not possible - it's a prod database....

sqlitetable circular reference

I'm trying to create a self referencing table using sqlite, here is what I'm doing ``` export const forms = sqliteTable("forms", { id: int("id").primaryKey(),...

Migrations are not run in order

I'm running through a problem (and I hope I'm writing in relevant channel). Context: I have an existing RDS Aurora Postgres Serverless v2 cluster & I'm able to run the migrations perfectly (as per git current head). ...

sql magic operator with dates?

We were using drizzle orm but We implemented by ourselves a "multi-update" query to update fields based on different primary keys using the CASE ... THEN postgres syntax, this forced us to use the sql magic operator. Is there a way to integrate the sql magic operator with the timestamp type or with other custom types?
sql`WHEN ${where} THEN ${value}`
sql`WHEN ${where} THEN ${value}`
...

LibSQL type errors when using `drizzle-orm/libsql` import

Hey y'all. I am just beginning my drizzle journey, and am trying to set up a query to run in an AWS Lambda base-image container. I am using this guide for getting set up with Turso as my example. If I exclude the drizzle connection syntax, it all works fine. If include it, I am seeing type errors when I run tsc src/index.ts. If I just ignore them and fire up the container, I can get my TypeScript to build, but when I try to call the function, I see errors importing the libsql client library provided by the drizzle-orm package. Any ideas what might be happening here?...
No description

For update skip locked

Is there a skip locked option given a .for('update') in the select clause in drizzle?

Schema out of sync

Somehow my DB schema and my code got out of sync. Specifically, I have an ON DELETE CASCADE clause in the code that is not set at the DB level. Is there any way to ask drizzle to sync the code and the DB schema? Trying to generate a migration does not do the trick.