Drizzle Team

DT

Drizzle Team

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

Join

Modularize with Fasitfy and multiple Drizzle instances (NX Monorepo)

Hello folks hope u all having a good one! Quick question. I aim to create a series of Fastify plugins that are independent and composable. Each plugin should implement it's ownset of features. In this way our team can move fast and reuse a specific set of those plugins (and create other if needed) when a new project starts. I wan to use this dreadful and terrible (no better than Prisma) ORM to handle the persistence layer of those plugins....

Get Raw query string of a relational query in drizzle

I need the raw query string of a relational query to perform an explain command. The docs only explain this process for the non-relational queries :/...

Drizzle support SELECT FOR UPDATE of postgres to avoid logical race conditions ?

I have a similar use case like this: https://on-systems.tech/blog/128-preventing-read-committed-sql-concurrency-errors/ Currently I use a mutex in my node main process, but I think is better to move this to the db. If is possible can you show me a minimal example ...

What are the differences in executing prepared statemenst?

Hi everyone! Given the following examples from the docs: ```ts const p1 = db...

Schema Type Issue: Property 'user' is incompatible with index signature.

The schema does not accept any values for some reason. I'm using one file per table method and exporting all of its constants from index.ts file(sc attached). No idea what is the error here. Can someone help, I've already lost too much time.
No description

createInsertSchema forgets .$type() on text json mode fields in sqlite

for example: foodThemes: text("foodThemes", { mode: "json", }).$type<foodThemes[]>(), foodThemes will be referenced as JSON...

No such table: main.__old_push_[TABLENAME]

Hello, I tried to setup Lucia Auth with DrizzleORM and Torso LibSQL. The database reads/writes work via drizzleORM but when i want to create a user via Lucia Auth i get the error from the title. Does anyone have an idea?...

Does Drizzle autogenerate prepared statements under the hood?

Supabase is telling me that PGBouncer and their own Supavisor both don't support prepared statements. We don't use prepared statement but I see queries that look like autogenerated prepared statement ids If so, can we disable it?...

Query vs Select

Hello! I'm reading through the docs and absolutely loving Drizzle! One thing is still not clear to me is when to use query (https://orm.drizzle.team/docs/rqb) vs using select (https://orm.drizzle.team/docs/select). Are there performance implications, am I'm missing some differences in behavior, or it's just matter of preference? Thanks a lot!!...

are timezones saved as utc? for pg

im having an issue where the db is saving -2 instead of -1

Creating composite types in PostgreSQL

Hi, I'm curious how I could recreate the following code using drizzle. ```sql -- composite type CREATE TYPE author AS ( name text,...

Can't reference an array of enum in a table

I'm trying to define a column in a table such as: abilitiesRequired: abilities("abilitiesRequired").array(), but I get an error saying that abilities[] does not exist. How should i define that column so we can have one or multiple enums in ? ...

Attempting to get a Joined Subquery query into drizzle crud api

I was trying to get the following native sql query into a drizzle query ```sql SELECT au.id, au.firstname,...

rpc error: code = InvalidArgument desc = Invalid default value

When I do drizzle-kit push:mysql I get the following error: ``` Error: target: (dbname).-.primary: vttablet: rpc error: code = InvalidArgument desc = Invalid default value for 'created_at' (errno 1067) (sqlstate 42000) (CallerID: 12s8gn7khn0atcm380g0): Sql: "alter table posts modify column id varchar(36) not null", BindVars: {REDACTED} at PromiseConnection.query (C:\Users...) at Command.<anonymous> (C:\Users...)...

createSelectSchema & createInsertSchema does not infer array properly

Hey there, I have a table with an array of text text('col_name').array() The issue? Well when I try to call my drizzle-zod create and insert schemas, TS does not understand and tell my the col_name is a string instead of string()...

Does anyone have an idea why the column definition is wrapping the dataType with " ... "

This is making the whole SQL expression invalid. If I remove manually the " .. " around the expression it works. This is the result of running drizzle-kit generate:pg https://github.com/drizzle-team/drizzle-orm/issues/247#issuecomment-1742110943...

error: there is no unique or exclusion constraint matching the ON CONFLICT specification

Hello, I'm facing a problem with the insert on the table when I use the onConflictDoUpdate with targets that are not the primary key. Check the table below: ```ts export const product = pgTable("product", {...

How do I create a generated and stored column with drizzle-orm? Target db is Postgres

Hello 👋 , can someone point me to how I should go about creating a generated column for a table that is defiend using drizzle? Database is Postgres if that matters.

Drizzle Kit: Push Wants to Update Unchanged Column Type

Similar to this post: "1109290137688489984" Getting the following when running npx drizzle-kit push:pg ```...

Custom migration files? Triggers in SQLite

I want to do some triggers for sanity checks in my SQLite database and I know how to write the schema. Is there an escape hatch somewhere, that allows me to write my own up/down migrations? Am I maybe overthinking this, and should just add a .sql file into the migration folder?...