Drizzle Team

DT

Drizzle Team

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

Join

reference fails with Cannot read properties of undefined (reading 'id')

I have a foreign key reference that will not resolve. It seems that the other pgTable is undefined when it tries to resolve. I used madge to check and i have no circular dependencies. Does anyone have a strategy for how to find my error?

Drizzle not creating table

Hello, Do I need to manually create the tables? I have schema set up but its not creating the tables?...

Best way to insert thousands of records.

Hi, I've a use case where we get thousands of items from an API and I need to insert them into our DB. Right now my stack is node with nestjs+drizzle+postgres (aurora rds). As far I know the best option in PG for large inserts is to use COPY command....

using rqb with pgSchema

Trying to use rqb to access table within my "auth" postgres schema, but it seems that rqb hit the public schema I can access db.query.member even if member is within auth schema, definied with auth.table("member" , ...) Is there anything I'm missing ? difficult to find infos on how to perform query in this case on the doc...

How to specify types for raw sql statement?

How do I specify the types for a raw sql statement? I have the following code, but I have to override the types to unknown before I can get the types out. ```typescript interface SQLResults { numResponses: number;...

refine and createInsertSchema

createInsertSchema accepts and option to further refine the schema I would like to validate fields against each other like ensuring a completedAt field is date after a startedAt field. ```...

Changing postgres timestamp mode (string -> date) isn't reflected in migrations

Hi. I have my migrations generated and applied from my initial schema. Now in the schema I changed to mode: 'date' in multiple timestamp columns (ex: time: timestamp({ withTimezone: true, mode: 'date' }).notNull(),). This was mode: 'string' by default previously. Now when I run the drizzle-kit generate command, no migrations are generated. I made this change to multiple columns. ...

Conditional queries with $dynamic

Is there a way to not execute the query yet within the if statement? ``ts const countQuery = db .select({ count: sql<number>count(${recipeTable.id})`.mapWith(Number),...

Define a full-text search index using raw SQL concatenation

Hello, I have a posts schema that looks like this: ``` export const post_schema = pgTable( 'posts', {...

Schema review

Is there anything that can be optimized about the schema below:

CTE / WITH + alias

Playground: https://drizzle.run/zb932yr9sv2w1nzn916wzvdt How can i generate the same SQL code (left join "bar" as cte1) without``js sql${cte} as cte1`...

Can't find ``all`` option on join

In this example: https://orm.drizzle.team/docs/joins#many-to-one-example They use a .all(); at the end to get more than 1 joined element. I'm trying a very similar thing and there is no all function: ```js let orders = await database...

Search on user's fullname

I have a user's table that stores first, middle and last names, I want to create another field named search that can be automatically calculated from these three fields. I saw something on the docs about something called full-text search, but I don't think that is is needed for my case, I just to be able to find users based on any part of their name provided. I am not a postgres expert, so I will appreciate any advice if I am wrong....

Drizzle is not working properly and not creating tables

drizzle studio is not working properly and it only take one table it is not accepting the new tables which i am creating
No description

securityInvoker

Hello, while generating the schema in version "drizzle-kit": "^0.30.4", the securityInvoker field comes as string while the (documentation)[https://orm.drizzle.team/docs/rls#rls-on-views] says its a bool . Is there a fix for this?...
No description

What's the hash in the __drizzle_migrations table used for?

I was wondering what the hash in the migration table is used for? I was playing around a bit to see what happens when I did a drizzle-kit push and manually update the migration table.. It seems to work by just updating the created_at timestamps to the when timestamp in the journal. Is it safe to do this? What is the hash used for and when could this create problems?...

No Such Index w/ .unqiue() Constrain

Hello! I am running into a issue using sqlite / turso where when applying a .unique() constraint and running db:push it is giving the following error: ```...

Self join breaks return type

Same issue as https://discord.com/channels/1043890932593987624/1286374226667896914 The return type of the query is never[]. If I remove the left join, things return to normal. The query works as expected, the result is just never[]....
No description

multiple schema files

Hi im a bit confused on how to use multiple schemas. When i use mutiple files, db._.fullSchema retuns a emty object. this is my drizzle config: ```ts import "dotenv/config"; import { defineConfig } from "drizzle-kit";...
No description