Drizzle Team

DT

Drizzle Team

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

Join

drizzle-kit push keeps trying to drop and recreate the same constraints

``` │ALTER TABLE "authenticator" DROP CONSTRAINT authenticator_userId_credentialID_pk; │--> statement-breakpoint │ALTER TABLE "authenticator" ADD CONSTRAINT authenticator_userId_credentialID_pk PRIMARY KEY(userId,credentialID); │ALTER TABLE "account" DROP CONSTRAINT account_provider_providerAccountId_userId_pk;...

Using Zod objects generated from drizzle zod with ts-rest . Parameters interpreted as optional

Hey I am trying to use drizzle zod to generate zod objects to be used in my ts rest contract. however when I try to use this contract in my handlers the fields in the body being passed are interpreted as being optional and not mandatory contract ```...

TypeError: Cannot read properties of undefined (reading 'isRLSEnabled')

TypeError: Cannot read properties of undefined (reading 'isRLSEnabled') I am getting this error when using Drizzle kit push I am using Supabase. I recently updated the Drizzle Orm and Drizzle Kit and I was not getting this error before the update....

Deprecated pgTable signature

I'm seeing this as deprecated, but not clear on what the correct / up to date usage should be: ``` export const providerServiceAreas = pgTable( "provider_service_areas",...

database design suggestions

i am creating a minimal issue tracker application, the user flow is as follows: - user signs in (passwordless auth) - creates a username (if signing in first time) - creates a project - creates custom priority levels...
No description

Help with relations: many-to-many + one-to-one

I'm having trouble figuring out how to model the following relationships between papers, authors, and author's names with Drizzle relations. The schema looks like this (I've ommitted some columns for brevity) ```ts export const authors = sqliteTable("authors", (t) => ({ authorId: t.integer().primaryKey(),...

Possible to infere type from PgEnum?

how to get the type of something like this export const serenity = pgEnum("serenity", ["ok", "warning", "critical", "error"])...

Are hierarchical rows possible?

Would it be possible to do something like this?
No description

is there a way to use custom functions without raw sql?

i'm using functions from a postgres extension. is there a way to use them in queries without baking in raw sql?

Evolving form data and typesafety .

I'm building an app where clients submit forms and professionals can subscribe to them. The challenge: Each service (cleaning, plumbing, etc.) has its own unique form structure. Professionals can subscribe to specific services and filter based on form fields (e.g., "only show me residential cleaning jobs"). The main problem: When service forms evolve over time (adding/removing/modifying fields), I need to preserve old submissions exactly as they were submitted. However, this breaks TypeScript/Zod type safety. ...

relation columns name

can someone explain me why my relations columns names are like this? I think this was supposed to be just: [tableName] and not: table_name_column_name, am I wrong ?
No description

Error introspecting a MySQL database

Hey guys!! I'm getting the following error when using npx drizzle-kit pull against a MySQL database: ``` code: 'ER_UNKNOWN_TABLE', errno: 1109,...

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]:

when I am trying to run the npx drizzle-kit studio I am getting an error, PFA. ```json { "private": true,...
No description

Issue with importing drizzle from drizzle-orm

I am following Theo's From 0 to production tutorial. when i go to import drizzle from drizzle-orm/vercel-postgres I receive the below error: drizzle-orm/vercel-postgres"' has no exported member 'drizzle' I have made sure drizzle is up to date and the issue still persists....

Race condition executing a common pattern (select or insert)

I'm having trouble understanding how to execute a common pattern in Postgres and I'm using Drizzle as an ORM adapted. The common pattern is this: I want to fetch a single row by some query, for example ```ts let record = await db.query.records.findFirst({ where: eq(records.phoneNumber, '+15555555555'),...

Drizzle d1 client seems to be missing

https://orm.drizzle.team/docs/get-started/d1-new import { drizzle } from 'drizzle-orm/d1'; Error Cannot find module 'drizzle-orm/d1' or its corresponding type declarations.ts(2307)...
No description

How to Handle Incorrect Schema Generation with Drizzle?

Hi everyone! What is the usual practice when I generate an incorrect schema with Drizzle and can't successfully migrate? Is there a command to delete the previous migration/generation? Because no matter what I change afterward, it keeps throwing the same error. For example, I have two tables that I linked together, but I later noticed that one has an int column and the other has text. Even if I fix the schema, regenerate it, and try to migrate again, it still throws the same error. How should I properly handle this? Thanks in advance! Error example: ...

How can i execute an actual `select star` query?

I want to write some CTEs. I used db.select().from(table) method, but it will generate an sql like select [...Columns] from table. how can i modify it to actually get select * from table in the generated sql?

How to keep dev and production DBs in sync?

I'm using Drizzle in a SvelteKit project. My local database is Postgres run via Docker. My production and staging databases are Postgres on Railway, also via a Docker instance. I'm wondering how to keep these in sync? Local development with drizzle-kit generate and drizzle-kit migrate is working well, however I'm running into an issue where a PR I'm merging has so many schema changes that that the migration files generated for my local config aren't successfully being applied to my production database. I get errors like these: ```...

Migration production safety questions (concurrency, rollbacks, out-of-order application)

Hi, Community! New to Drizzle, investigating it as a candidate for next larger quite heavy production project, decided to test something new instead of battle-tested knex to get better TS support 🙂 DB is PostgreSQL, but I think it's not essential So have few questions which come from experience 🙂 I could spend time indo digging into code, but decided to ask first if someone is aware of behavioural details here....