Drizzle Team

DT

Drizzle Team

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

Join

can someone help me with this relation?

export const Worklog = mysqlTable('tasks', { id: int().primaryKey().autoincrement(), ... other columns ... categoryId: int("cat_id").notNull().references(() => WorklogCategory.id), .. other columns......

Drizzle Studio bug report with error context, local libsql.

installed libsql locally, created the db with "pnpm drizzle-kit push" which worked without problems. "drizzle-kit": "^0.30.5", "drizzle-orm": "^0.41.0", "@libsql/client": "^0.15.0", attached is the bug report with the error context.....

Using prisma to select columns not returning what I'm passing

I'm not sure what is happening. I'm in the process of switching to Drizzle from Prisma and am having an issue with my query that is causing the select object I'm passing to not be respected and just returning the columns for one of my tables. I have this query trying to select some specific columns from each of my tables ```javascript db.$drizzle .select({...

joins overwrite select?

Am I crazy or this is not supposed to happen? My schema is: ```js...

Introspect on a Supabase project -> non existing `userInAuth` relation

I'm trying to run drizzle-kit introspect on an extremely simple project, with little more than user authentication. Everything seems to work fine, but the generated relations.ts tries to import and use userInAuth from the generated schema.ts But that it's not exported ( or created ) in schema.ts. I believe that has something to do with Supabase having an auth schema, that has a relation with the users table I'm using on the public schema. But, how I'm supposed to manage this structure with Drizzle? ...

drizzle-zod insert/update schema refinements type

I usually want to apply same refinements to insert and update. To avoid duplication I want to define them in an object. How can I type it properly so that it knows the type of the schema arguments, etc.? ```ts type TableRefinements = ... ...

Double Slash in Path Causes ENOENT Error When Running Migrations in Docker

Hi everyone, I’m encountering an issue with Drizzle Kit when running migrations in a Docker container. The error occurs because Drizzle Kit is trying to read the 0000_snapshot.json file using a path with a double slash (//), like this: ENOENT: no such file or directory, open './/app/apps/my-app/src/drizzle/meta/0000_snapshot.json' The file exists at the correct path (/app/apps/my-app/src/drizzle/meta/0000_snapshot.json), but the double slash seems to be causing the issue. Here’s what I’ve tried so far: ...

do I still need to use drizzle-kit?

I"m not doing any migrations or generation. Just doing selects, inserts, and updates into existing tables. I have most everything working and didn't instal drizzle-kit. But not sure how to do relations so not sure if drizzle-kit plays a part there?

update many to many relationship

I'm working with Drizzle ORM and have a many-to-many relationship between projects and users using a projectUsers join table. When updating a project's members, I see two possible approaches: 1- Delete all existing members and reinsert the new ones 2-Selectively update the members...

TypeScript Error: Circular Reference in Drizzle ORM Schema

Hey everyone, I’m getting TypeScript errors in my Drizzle ORM schema due to a circular reference. Here’s the code: typescript Copy Hey everyone, I’m getting TypeScript errors in my Drizzle ORM schema due to a circular reference. Here’s the code:...

rewrite with db.query

hello there... how can i write it with db.query, as this is chatgpt generated code and it gives me desired results but i want to write it with db.query ```ts export const getPublicNavbarCategories = () => { return db...

Drizzle & NextJs CI/CD

Hi there, i am trying Drizzle in a new project. Local dev is super easy but from the docs it's not clear how to handle CI/CD when deploying to staging/prod. Now i resorted to just add a
"postbuild": "npx drizzle-kit push"
"postbuild": "npx drizzle-kit push"
script, but I don't know if this is the best way to handle it.. ...

Entities missing or docs out of date for 0.40.1

entities for migrations and config are missing from version 0.40.1 https://orm.drizzle.team/docs/rls#migrations dont see anything in the changelog about this you can see in the photo previous config type that matches what the docs say for RLS entities...
No description

Generated columns / JSONB-ish querying

I am new to PostgreSQL databases and have found Drizzle to be the perfect option for interacting with a database in my application. I have been running into a problem which can most easily be explained with an example, and that I know I will have to deal with repeatedly in the future as well. I have an app that allows users to sort product offerings using filters. Offerings have various properties which must always be present (title, description, etc) and a large amount of optionally relevant properties (documentation, location, terms, etc) which should be available for filtering (filter only offerings located in "Kansas"). Currently I am storing all the potential properties as columns in a table "offeringProperties", but this is not scalable, and this issue will continue to crop up....

error while applying the migrations

Hey folks here is my code https://mystb.in/37323971356998692b currently I have set DATABASE_URL to file:./dev.sqlite after generating the migrations using the drizzle-kit generate when I apply the migrations drizzle-kit migrate I get the following error ``` [⣷] applying migrations...LibsqlError: SQLITE_ERROR: near "(": syntax error...

Issue with migration [push, migrate] command in postgressql

Added a link as well for better readability [contains same content as the steps.txt] https://rentry.co/drizzle-postgress-const-issue I am using postgress on supabase, checked on docker as well same issue is replicated. And unable to to push after pushing second time...

Generic `select`

trying to make generic selects. How can I do this? My attempt right now ```typescript // Fetch active quests from the database export async function fetchActiveQuests<TSelection extends SelectedFields>(fields: TSelection) {...
No description

Init Drizzle with cloudflare env variables

I'm trying to connect my database with the drizzle adapter. My backend will be hosted on cloudflare workers (with hono) so I can't use process.env to get my environement variables. How to get my cloudflare env variables to the db init ? Thanks for your help! ...

How do I seed my Cloudflare D1 db?

I have created a simple schema ```schema.ts import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; export const users = sqliteTable("users", {...

Drizzle Kit: Postgres View Schema Updates Not Detected

Drizzle Kit push doesn't recognize changes to Postgres view schemas. Manual delete/recreate is required. Is there a fix?