Drizzle Team

DT

Drizzle Team

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

Join

Queries require "await"?

I just tried to do a simple ```ts db.update(usersTable) .set({ [slot]: itemId })...

How to accomplish the following JSON format on retrievals

How can I format my query so that drizzle returns a property like so: ``` Book { bookId: 1, title: 'Book title',...

i'm trying to migrate my databse

```ts import { drizzle } from "drizzle-orm/mysql2"; import mysql from "mysql2/promise"; import "dotenv/config"; import * as schema from "./schema";...

How to set a GIN index on the JSONB column?

How can I set a GIN index on the whole jsonb column and also on a single column? ```ts import { sql } from "drizzle-orm"; import { index, jsonb, pgTable } from "drizzle-orm/pg-core";...

Updated to the latest and I get this error

Invalid input Please specify 'dialect' param in config, either of 'pg', 'mysql' or 'sqlite'  ELIFECYCLE  Command failed with exit code 1. drizzle-kit: v0.22.1 drizzle-orm: v0.31.0...

When using a foreignKey({}), is there a way to specify onDelete: "cascade'?

I'm looking to custom name my foreign keys so I need to use the foreignKey() function. However, how can I specify an action: {onDelete: "cacade"} using this function? ```ts userIdReference: foreignKey( { columns: [table.userId],...

Multiple subqueries with .with

Hey all - thank you in advance for the help I'm trying to port a SQL query over to drizzle and am struggling with using multiple CTE in one query. I'm not getting any type errors in my project but in the studio I'm getting "this isn't a valid drizzle query" and I'm not getting any results when I run it in place. I'm more than happy to refactor the query if it helps....

Ok to delete old migration files?

Would it be ok if I deleted all of my historical, applied migration files assuming they are stored in my git history? What about meta snapshot.json files? Thanks for the help!...

Default Rows

Hi! Is there any way to set some default rows in the table by drizzle?

Is there a way to do a "down" migration with Drizzle?

I'm looking at the docs of Drizzle migrations and I can't seem to find how to write migrations that can be rolled back.

Losing kysely types (using Kyselify) - getting [x: string]: any

Hello. I have some types problems using kysely with drizzle. I have the following config: ```js...

push won't work

I just got started using Drizzle & Drizzle-kit, but I've been running into some strange issues. I created a table, pushed that table, tried to rename a column in that table and now I get the following result: 1. Rename the column in the jobs table 2. rename the jobs table to __old_push_jobs 3. create a new jobs table with the old, incorrect configuration...
No description

How to get count with main query

Hi. Can i combine these two queries? ```javascript const data = await db .select({ id: S.appointment.id }) .from(S.appointment)...

Helpers for querying in the new PostGIS Geometry type

Hi, I was playing around with the new types and I wondered if there are some utility helpers for querying the point. For example: ```typescript const stores = pgTable("stores", {...

drizzle-zod not working with column of type vector (as introduced in latest release v.0.31.0)

Tried using createSelectSchema() on a table that has a column of type vector, e.g. ``` ... embedding: vector("embedding", { dimensions: 384 }),...

Reusable pgTable column helper - losing type : [x: string] instead of user_id

Hi, I am trying to create a reusable column to use accross multiple tables. If I use the following : ```js export const userId = char("user_id", { length: 10, }).references(() => users.id);...

Drizzle Studio Not Showing Tables that are in Supabase

I am starting to work on a project and using Drizzle and Supabase. I just did a drizzle-kit generate followed by a drizzle-kit migrate. When I look in supabase.com it shows that table. However, when I run drizzle-kit studio, I just get a spinner. This is what my drizzle.config.ts looks like ```ts import { defineConfig } from 'drizzle-kit' import { env } from '@/app/env'...

Is it okay to manually edit migration files?

I recently had a migration file execute commands for dropping a table in the wrong order. Can I reorder them manually? This wouldn't result in any schema changes technically....

Can't apply migration?

The following migration file was generated by Drizzle-Kit ```SQL DROP TABLE "worker_pay_period";--> statement-breakpoint ALTER TABLE "pay_stub" DROP CONSTRAINT "pay_stub_pay_period_id_worker_pay_period_id_fk";...