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 I add a Unique constraint to a column?

I couldn't find an option for that in the docs. I'm assuming Drizzle doesn't support that. So, could I just edit one of the migration SQL files myself and add the UNIQUE constraint to it? Or would that break things?...

"Cannot parse date or time" using AWS Data API, aurora postgres

I'm trying drizzle-orm (with sst) and aurora pg thru aws data api, when trying to insert a Date value in a column (timestamp with timezone), I'm getting this error. I wonder if the problem is the way Date is being serialized (looks like it's not using ISO date string?) this shows the response coming from aws-data-api ```...

Filtering against a relation

I have a orgs table that have a many to many relation with a users table. while querying with the findFirst method how can i filter against the relation so that I only return an org if the user have access to it....

Get type for select query?

Hey guys, is there a way to infer the "select" type for a given table? for example: ```ts async getUsers(selectColumns: ?) { return this.db.select(selectColumns).from(users)...

orderBy related table column

Given a relational query such as ``` const matchResult = await db.query.matches.findMany({ where: and(...

Soft Delete Strategy

I'm a person of eloquent taste; one who prefers the soft delete. With the current feature set of drizzle, how is everyone pulling this off currently? My personal favorite when using Postgres is by using partial indexes; such as this article describes as I must deal with uniqueness and wish to not index deleted data. https://gusiol.medium.com/soft-delete-and-unique-constraint-da94b41cff62 ...

Columns that not allowed to updated

Hi guys, I'm looking for a proper way to declare SQL schema and its InferModel types when there're columns that are not allowed to update programmatically. Will there be sth like uuid().const() or text().static(),... for that type of columns? and then InferModel will only accept updatable column. I'm new to SQL and drizzleORM, below is my current implementation....

Execute sql with '?' as parameter

Hello everyone. Please, how do I execute a sql that uses as a parameter the character '?' ? For example const sql = 'select * from table where filter = ?' db.execute(sql, ['filter'])...

Foreign Key Reference to auth Schema Not Generated in Code

I'm having an issue with my Drizzle-ORM code where the foreign key reference to the 'auth' schema is not being generated as expected. The issue lies in this block of code: ``` import { index, jsonb, pgSchema, pgTable, text, uniqueIndex, uuid } from 'drizzle-orm/pg-core' ...

How can I add a Prefix Index?

I migrated from Prisma, and I have a column with varchar(2000) which I indexed with @@index([columnName(length: 191)]) but the introspection schema didn't seem to recognize the index length:
columnNameIdx: index("TableName_columnName_idx").on(table.columnName)
columnNameIdx: index("TableName_columnName_idx").on(table.columnName)
...

connect to local postgres

Does anyone knows how to connect to a local pg with neon? I tried: ``` import { neon, neonConfig } from '@neondatabase/serverless'...

defaultNow(), onUpdateNow() not available on the datetime data type

I'm able to build this into my database, but I'm not able to express it through drizzle. What gives?

NeonDbError: db error: ERROR: permission denied for schema drizzle

Created a new database on neon.tech today and trying to run migrations ``` // src/db/migrate.ts import { neon } from '@neondatabase/serverless';...

How to implement a where clause on a joined table with the new relation builder?

This was my original query, the big problem is that it returns as many rows as there are messages instead of one entry with multiple messages. As you can see, I have a where clause where the entry is filtered with it's id, and a organization id that is part of another joined table named channel. ``` const tickets = await db .select({ id: s.tickets.id,...

Error when deploying migrations with GH Action in Cloudflare D!

I'm trying to run migrations within a turborepo against a Cloudflare D1 instance. The command to run is this: wrangler d1 migrations apply d1_turbolang --preview I can run it from local (VS code) but when put it into an Github Action I get this error...

0.27.2 mysql:push

mysql:push in 0.27.2 is trying to alter my primaryKey with no schema changes. it also seems to try and drop a constraint that doesn't exist yet? I think it's something to do with the unique index changes...

Creating an abstract base repository

Hi, I'm trying to create a base repository for my application but can't make it work. Is it even possible? Here is what I'm trying to do: ```ts...

XCannot be named without a reference to '../../../../../db/node_modules/drizzle-orm/driver.d-f4e534

I have a monorepo with a dedicated database package that handles everything around the database, and then exports a db "connection" object , and also some ORM methods. I associated packages ... I get this error when importing from that package ... any ideas welcome.

How to do conditional joins with the query builder?

Hi, I'm looking for a way to do conditional join's without working with AnyPgSelect. Thanks in advance.