Drizzle Team

DT

Drizzle Team

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

Join

node-postgres uses crypto under the hood ?

Hello everyone, so I'm migrating from Prisma to Drizzle so I can use the NextJS's edge runtime I'm trying to make a query inside my edge middleware and I get the following error: The edge runtime does not support Node.js 'crypto' module. ...

SyntaxError: Unexpected identifier 'SCHEMA'

I'm trying to execute "drizzle-kit generate:pg" and I'm receiving error: CREATE SCHEMA "boards"; ^^^^^^ SyntaxError: Unexpected identifier 'SCHEMA'...
No description

How can I create a virtual table with sqlite?

I am using turso & sqlite. I have enabled the FTS5 extension so I can perform full text search. I want to define a virtual table in my schema so I can query it using drizzle. If I define it as a regular sqliteTable, running db:push from drizzle kit will create the table and break the virtual table. What's the best way to proceed?

Is it possible to identify modifications in a pg db and extract/pull them as a new migration file?

Here is the situation I am referring to: 1. When I run drizzle-kit introspect:pg for the first time, it generates 0000 migration. 2. A new table called my_new_table is created using native pg (without ORM). 3. (I wish to) When I run drizzle-kit introspect:pg for the second time, it generates a 0001 migration with my_new_table included....

PostgreSQL "type serial does not exist"

I'm getting an error when using serial and primary key. Just trying out postgres for the first time so its very possible I messed something up, the serial type works perfect on non primary key fields ```ts export const users = pgTable( "users",...

how to express the "children" relation in parent/child?

I have a table with columns id and parent_id - and I want to setup a parent/child relationship. Using the relations, one, and many I've got this but not sure if it's correct. If I'm able to express my "parent" relationship, shouldn't I also express my "children" relationship as well?...
No description

Too many clients already (!?)

Hey guys, been using Drizzle for a few weeks now and I think since last week this issue has started (look at screenshot). I'm using the postgrespaackge to connect Drizzle to my PostgreSQL database that's deployed to Railway. Drizzle connection code 👇 : ```typescript...
No description

Help, issue that will drop our user table

We generated and pushed our schemas to a dev branch in planetscale, and then deployed that branch no issue. One of the schemas was the User schema. We added two schemas to our db and pushed to dev again, no changes were made to the User schema, yet pushing to the dev db wants to truncate our user table because of the createdAt and updatedAt columns. What is happening and what should we do? Schema ``` export const user = mysqlTable(...

How to use a composite primary key in WHERE?

I have a table dv360UserProfilesTable which uses a composite key of userId and assignedUserProfileId. If I want to update this table, I'm struggling with how to use the composite key to batch update profiles. The below code throws the error: db error: ERROR: argument of WHERE must be type boolean, not type record The docs also do not show an example of this https://orm.drizzle.team/docs/indexes-constraints#composite-primary-key ```...

Having statement to compare sql<number> and number

Sorry if a dumb question, I'm working on an aggregation query like: ``` const query = await db .select({ workerUid: workerStatsDaily.workerUid,...

Select EXISTS

How to query boolean value if row exists or not. In pure sql it will be like this:
SELECT EXISTS(SELECT 1 FROM your_table_name WHERE id = 1 AND version = 5)
SELECT EXISTS(SELECT 1 FROM your_table_name WHERE id = 1 AND version = 5)
...

Zod schema validation from Drizzle schema

Hello i have an issue with zod creating schema from drizzle. I don't understand why my categories won't works while my customers works with the same export code feel free to ask more elements I know that it could be a zod issue but there is no one active on their server and maybe someone here can help since i had recommandation tu use zod in this discord server...

Each element of array is a foreign key

Hello, I'm trying to figure out how to create a postgres schema that will hold an array of ids property, and each element of that array is a foreign key. Is this possible with Drizzle? Here's my implementation: ```typescript...

Buffer isn't defined

I use blob mode:json for my fields and run it on Cloudflare Workers. But I get that Buffers isn't defined. As I understand blob only compatible with Node.

Is it possible to do lateral sub-query join without relational queries?

I'm trying to rewrite the same query that the relation query builder does behind the scenes but not sure if it's possible If i log the query this is what i get ```sql select "articles"."id", "articles"."title", "articles_keywords"."data" as "keywords" from "articles" left join lateral (select coalesce(json_agg(json_build_array("articles_keywords"."article_id", "articles_keywords"."keyword_value")), '[]'::json) ...

[Remunerated] Looking for help to switch my project from Prisma to DrizzleORM

Hi folks! Been building the MVP for my startup (https://CocktailAndDinner.com) using MongoDB & Prisma. Now, looking to switch to Planetscale + DrizzleORM. This can become an ongoing work, but for now I'm looking for a senior dev to mentor me....
No description

drizzle studio tables are empty

Hi, I created app using Next.js, TRPC and next-auth and I setup auth logic with Discord Provider, everything works fine except when I run drizzle studio all tables are empty even tho I can login without problems, anyone had something similar? btw I'm using sqlite...
No description

Bug on custom type inference? Maybe I'm doing something wrong.

```ts export const timez = customType< { data: Date; driverData: string;...

JSON with PostgreSQL not serializing correctly

I have define my field like this:
hostnames: jsonb("hostnames").$type<string[]>().default([]),
hostnames: jsonb("hostnames").$type<string[]>().default([]),
...

hashing password in Cloudflare Workers

Can someone help me find function to hash password and verify it that works in Cloudflare Workers