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 - Where to store relations?

Seeing as when pull operations occur it overwrites the local schema, is there a good place to keep relations? Just relations.ts somewhere in my project?

unknown command: drizzle-kit

Can't seem to get the command to work. Followed the instructions of the quick start guide. Any ideas?

Auth.js adapter import causes module not found error

Hey there! I want to build an authenticated app using Auth.js and the newly released Drizzle adapter. I've done the setup exactly as described here, but am getting the following error when running:
[ERR_MODULE_NOT_FOUND]: Cannot find module 'pathtoproject\node_modules@auth\drizzle-adapter\lib\mysql.js' imported from pathtoproject\node_modules@auth\drizzle-adapter\index.js
I.e. my hooks.server.ts file:...

Insert One to Many

How can I insert relations as well at create the parent? ``` import { Customer } from "@/types/customer"; import { NextResponse } from "next/server";...

Renaming pgEnum results in truncation?

I've been using drizzle with MySQL for a while, but I'm new to PG. I encountered an error where I had two different enums with the same column name status on two different tables, and Drizzle just chose one of the enums for the migration and didn't include the other. I was able to solve this by just changing the column names to project_status and comment_status (which might be better anyways, so its fine). But when pushing that migration I got a new warning saying that changing the column datatype from status to project_status would truncate the table, even though neither the enum datatype itself nor the default value had changed at all. Just the name. So I guess I'm just wondering if anyone has encountered anything similar, and if you were able to find a solution, or if this might be worth opening issue over. Or rather if I just clearly have a misunderstanding of how PG works, please let me know lol. Thanks in advance!...

Drizzle Kit + Planetscale example?

I was hoping there would be an example of how to integrate the two. Planetscales docs are just OK, so I'm wondering if anyone has done this before and would be willing to share some code,

Issue with Jest tests in Next.js

I seem to be hitting an error with Jest tests when using DrizzleORM in my tests. I get
Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
...

explain relationName please

Could anyone explain how to use relationName when you have many to many for example. Found following on github:
"relationName is already supported, just not documented. So you can use it exactly as you've described. You'll just need to add where clauses to the corresponding with entries."
"relationName is already supported, just not documented. So you can use it exactly as you've described. You'll just need to add where clauses to the corresponding with entries."
https://github.com/drizzle-team/drizzle-orm/issues/811...

Error While db-push

I last pushed a change 2 days ago, and this error didn't occur. Today, when I added description to it and tried to push, it gave me this error. I wonder why.

Type error: Type parameter has a circular constraint

Hi all! Trying to figure out this error I'm getting when running next build. Thought I'd drop it here in case anyone else has run into it or has any tips for debugging: ``` - info Checking validity of types... Failed to compile....

There is not enough information to infer relation

```js export const historyRelations = relations(histories, ({ many }) => ({ files: many(historyFiles), })); ...

Getting Invalid default on timestamp when pushing schema to Planetscale

Getting the following error. Is there another method instead of defaultNow() for timestamps?

How to flatten select results from query with left joins (one-to-many)?

Is there a way to achieve this? Current behavior in drizzle works like this (assuming we're printing the variable "result" which is supposed to be an array of person with all their hobbies, one to many: ```ts // NOTE: I've read a portion of the docs and it says something like //using a reduce function. I'm looking for a solution that is more // of an abstraction that works out of the box - just like how...

"mode" not defined in drizzle config 0.28.1

With the new update i've added the "mode" field for planetscale however my ts is mad at me

how to convert serial to uuid type

Hello I'm trying out drizzle but i'm stuck on a problem I created a todos table with id as serial type, migrated and pushed it to my db, now I wanted to change the type to uuid but the following error appears on my console PostgresError: column "id" cannot be cast automatically to type uuid...

how to make a session using drizzle

```ts import express from 'express'; import session from 'express-session'; import genFunc from 'connect-pg-simple'; ...

Aws Rds with drizzle

My Schema on Aws Rds is not updating , once i update my schema and generate the schema , i am not getting any errors but still the migrations seems to fail , when i try to insert into that table BadRequestException: ERROR: relation "fuc" does not exist Position: 13; SQLState: 42P01 I get this...

Error: Can't find meta/_journal.json file when trying to apply migrations in a lambda

I'm trying to apply migration in a lambda locally with running sls invoke local -f db_run_migrations I use serverless framework with the serverless-esbuild plugin to package my lambdas I execute the lambda using the sls invoke local -f db_run_migrationscommand This is my folder structure and lambda handler...

Nested joins / where on relation

Hey guys! I have a question regarding filtering a query. Basically, I need to filter the query by order relation - order.date is the field I want to filter by. However, I've noticed that filtering by relations is not yet supported. How do I write the query with joins? I can't figure out how to created nested joins (subOrders -> order and subOrders -> product -> kitchens -> kitchen etc.) This is my query: ```ts const suborders = await db.query.subOrders.findMany({...