Drizzle Team

DT

Drizzle Team

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

Join

instanceof postgres.PostgresError not working

How can I check the error is of instance PostgresError ? It seems the condition is not met... Even though when console logging the error its clearly a postgres error: [Error [PostgresError]: duplicate key value violates unique constraint "..."] {...

drizzle-kit skill issues

So I had several schema files under a folder, all the past migrations were ok, today i wrote new migrations, and edited a file called school.ts to schools.tsto be consistent with other file names (plural), when I did drizzle-kit gnerate it said couldnt find the old school.ts, i said fine and reverted back to school.ts i do generate again and now saying schools.ts is missing, so now i have both school.ts and schools.tx the migration passed with both files but i dont think this is right I cleared node_modules and pnpm cache nothing, reinstalled deps dint work, am on nextjs, turborepo so right now i comment out school.ts so i dont import it and when i need to do migrations i have to uncomment it🥲...

Migrate only up to a certain migration

Due to the system I'm running I need to run a migration up to a certain point, then run some logic, and only then keep with the normal migrations. This is because the logic I need to mutates data in a certain way. Is there a way to tell this to migrate()?

"There's not enough information to infer relation"

```ts export const userRoomsRelations = relations( userRoomsTable, ({ one, many }) => ({ owner: one(usersTable, {...

Array of enums wrong type

Hello! I'm trying to migrate a column from enum to an array of enums, like this: ```ts...

Numeric

`` I'm working with Drizzle ORM and have a numeric column defined like this: ```typescript cost: d.numeric({ precision: 10, scale: 2 }).notNull().default("0.00"),...

left join not properly hydrating results

```ts tx .select({ ...getTableColumns(projects), clients: { id: clients.id, name: clients.name },...

Drizzle-ORM Installed but Drizzle Can't Find its Config?

I'm trying to follow the docs to install Drizzle with Postgres on my React Native Expo starter, but no matter what I get this: ```error pnpx drizzle-kit push --config=drizzle.config.ts ...

Can't use legacy db._query on drizzle beta version

here is my db code: ```ts import type { Logger } from 'drizzle-orm'; import { defineRelations } from 'drizzle-orm'; import { drizzle } from 'drizzle-orm/postgres-js';...
No description

Can has mutual-exclusion?

eg. data: json or error: string but not both

Local first with sqlocal and drizzle

Hello, please I need some help especially if anyone have experience using the sqlocal database. I am using sqlocal (https://sqlocal.dev) on my frontend with Sveltekit. I followed the docs to set it up with drizzle ORM. But while trying to do an insertion, it says "no such table: products" I guess there's a way to initialize the database with the appropriate tables, but am not finding that in the docs....
No description

Types seem weird...

Am working with drizzle, and have my table, where it just seems to be acting a little bit weird (ignoring primary key for the infered insert) Though it is working without throwing an error 🤔 so very weird.
No description

getting the returning data after inserting record as string | undefined instead of string

Hey folks here is my drizzle schema ```ts import { createId } from "@paralleldrive/cuid2"; import { relations } from "drizzle-orm"; import { boolean, index, pgTable, text, timestamp, unique } from "drizzle-orm/pg-core";...
No description

How do I make Drizzle infer the correct return type when dynamically adding a custom select field

I'm building a query using a helper like this: ``` export function createBaseVideoQuery<T extends Record<string, any> = {}>( customFields?: T ) {...

Error splitting schema in multiple modules

I was breaking down my old schema.ts module into multipe modules under a schema dir. I updated the config: ```ts import 'dotenv/config'; import type { Config } from 'drizzle-kit';...

Best practice for manual down migrations

Hi, I know down migrations are not currently supported by Drizzle and are WIP. However, I need to support this in my project, I'm happy to create them manually, I was just wondering if there was a best practice to do this and whether drizzle has any existing mechanism to execute any manually created down migrations? Thanks!

Is using "_" (underscore) safe?

I'm using underscore to get selected fields from subquery. I'm thinking it should be for internals maybe removed future releases? Example: ```typescript const sq = this.db.$with('prods_with_qty').as( this.db .select({...

Drizzle in Turborepo

How can I add drizzle to a existing turborepo?

SQLite auto-update timestamp

I'm trying to auto-update timestamp when using SQLite. This is my try, but it doesn't work: ```...