Drizzle Team

DT

Drizzle Team

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

Join

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....

$returningId is not a function

I am trying to get the ID of the newly inserted record I use mysql according to the document, I try to use $returningId but it doesn't work, my ide gives an error not found ``` const result = await db...

.array() can't automatically type cast

```typescript export const recurrencePattern = createTable( "recurrence_pattern", { id: serial().primaryKey(),...

Error 7500: not authorized: SQLITE_AUTH

Hello! Has anyone had this before? I'm running Drizzle with Cloudflare D1, when I do drizzle-kit push I get this error...

Json column type returning as plain string?

I have a schema for a json column (sqlite, proxy http driver) defined as: authors: text({ mode: 'json' }).notNull().$type<string[]>(),; and I'm able to save data into it by passing an array of strings: ['Mary Shelley']. However, when I run a select on that schema, I get back a string of the json: "[\"Mary Shelley\"]". Curious if that's expected, and/or if there is a way to automatically parse the resulting json. The type information for authors is showing up correctly as string[]. But the data is a plain string....

How would you write this SQL query using Drizzle?

Hey! This is my first time using Drizzle. I have the following SQL query, which returns the ID for "my_name" (which I expect to return most of the time). If the name doesn't exist, it will insert it into the table and return the new ID. It's one call to the database and avoids trying to INSERT only if the value doesn't exist. How do I write this using Drizzle? ```SQL...

error: password authentication failed for user "postgres"

I'm trying to connect to my DB using Drizzle. I run the command: drizzle-kit push Here is the config:...

How can I properly compile the type of schema?

Hello. I'm currently using Turborepo to manage the monorepo. I want to separate the schema declaration of drizzle to internal package. But when I tries to export typeof schema/drizzle instance, it loses the information about tables. I tried using tsc, esbuild, tsup but still no luck. Is there anyone successfully compiled type of the schema?...

Help with helper utils

@Raphaël M (@rphlmr) ⚑ I wanted to use use snippets for jsonAggBuildObject but unfortunately I am getting some ts error. https://gist.github.com/rphlmr/0d1722a794ed5a16da0fdf6652902b15?permalink_comment_id=5009839#file-clear-db-ts
No description

After commit hook for transactions

Hi, does somebody know whether drizzle has or is planning to add some sort of afterCommit functionality. I've seen some orms do it, and i think it wouldn't hurt drizzle to implement it....