Drizzle Team

DT

Drizzle Team

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

Join

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.

Filtering out tables during introspection

I'm using Planetscale, and they automatically create _vrepl tables in my database. Is there a way to filter out tables ending in _vrepl during drizzle-kit pull?

Optionally migrate a table.

Is there a way to tag a pg table to optionally migrate it when running either generate/migrate or push commands? There's a system generated table in my existing database and I know I can pull it to get the schema structure. What I don't want to do is change anything when I run the generate/migrate or push commands. Kinda like how managed=False works in Django....

`drizzle-kit pull` v0.28.0 generating faulty schema file

Running drizzle-kit pull generates an incorrect schema file. Ex: ``` export const inviteCodes = mysqlTable("invite_codes", { id: varchar({ length: 255 }).notNull(),...

Struggling with simple subquery statement in Drizzle

Hi friends, I have a complex query like so that I've made into a subquery: ```ts const query = db .select({ ......