Drizzle Team

DT

Drizzle Team

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

Join

ForeignKey Too Long

Hi Drizzle Devs ! I would like to know if you are working on the functionnality to customize fk naming because i can't fully migrate because my foreign key is too long...

Drizzle workflow on schema modification

Hi, can someone explain me the process to follow when we modify the schema to push modifications to database please. I'm working on 2 computers, and when i modify schema like adding constraints, when i go to my second computer, i run drizzle-kit introspect:mysql and push:mysql but no modifications are added, also if i drop my table and recreate it with drizzle push:mysl, constraints are not added to my tables....

Possible to have type from enum value?

Has you can see i am filtering all my users by type "clinician", supposedly its 100% sure that the output of this would be that the user type is "clinician", but it still picks up the other enum possibilities, is it possible to make it understand in the type inference that the user type will only be "clinician"?
No description

Creating join table that is simultaneously many-to-many and one-to-many

got a data modeling / sql question for you all: I have an entity A with either a many-to-many relationship to B, or a one-to-many relationship to C. There must be a unique ordering of all relationships from A to B or C, such that we can define an ordering such as B1, B2, C1, B3, C2... etc B and C are different entities, with wildly different table structures, and therefore cannot be combined into a single table. ...

Any way to replace null by undefined?

Before using Drizzle, I was using the type mapper and the transform option of postgres.js in order to transform undefined to null. That way, any inserted undefined would be inserted as null in the database, and any null value in the database would be an undefined in JS. I'm looking for a way to do this with Drizzle. AFAIU as I'm still using the postgres.js connector, I can continue with these options, so the issue is to use undefined instead of null in the types. Similarly to changing a column type with .$type<T>(). Thanks!...

Drizzle pagination with count

Hi, is there a way to have a paginated query that also count all posible results based on a condition? I have the following currently: `const result = await db.query.businessUsers .findMany({ orderBy: businessUsers.id,...

TRIGGERS in Drizzle

Is there a way to define/implement TRIGGERs in Drizzle? An example would be great!...

Migrating from Prisma Schema

I want to migrate away from Prisma, but I can't seem to find a good way to get the schema right: - Drizzle's introspect feature somehow generates garbage with VARCHARs deafult values, I saw that this seems to be a known issue on GitHub, so I suppose there is nothign I can do about that? - Then, while 1:1 relations seem to be covered, I can't get it to generate any (many:many) relations. How is that done by Drizzle? Does it use some kind of heuristics to detect relations? Our company's model has roughly 100 tables and for now we used Prisma to handle it, so we have a prisma schema in case that helps anything, but managing all relations manually is probably error prone and a bit of a problem. - Kysely has a nice generator to generate types from a Prisma schema. Can Drizzle also do that?...

[HELP]: I'm trying to re-create a CTE-insert in drizzle, having some difficulties

```sql with cart_products as ( select * from cart_product where cart_id = ${cartId} ) insert into order_product (order_id, cart_product_id)...

Add drizzle-kit check as a pre-commit hook

Is there a way to add drizzle-kit check as a pre-commit hook with husky that would actually prevent the commit if something is wrong with my migrations? Currently i can add it but it won't prevent commiting

Planetscale swapped the order of Primary Key Relation

Hey, running into this weird issue when using Drizzle push on a staging branch of Planetscale, trying to promote it to production In the screenshot you can see: - PRIMARY KEY (userId, serverId), + PRIMARY KEY (serverId, userId),...
No description

Postgres functions in the ORM?

Hello everyone, I'm learning typescript and SQL (with drizzle) and I'm trying to make an api endpoint that has something like this ``` const {name, owner, hidden, uuid} = updateServerDto; const upd = this.db.execute(...

InferModelFromColumns with columns defined with sql``

Let's say I have a select list that looks like this ```ts const defaultBookFields = { id: books.id,...

Issue with drizzle-zod?

Schema ``` export const testinArray = pgTable("testing_array", { id: varchar("id", { length: 14 })...

Optional One-to-One Relation

Currently it's possible to define only a One-to-One relation (https://orm.drizzle.team/docs/rqb#one-to-one) but in the types, the value returned will never be undefined or null. In my use case I would like to define a One-to-One relation that could be optional. Is there a solution? Is this even possible? (I also raised an issue on GitHub (https://github.com/drizzle-team/drizzle-orm/issues/1066) a month ago but I think it got lost there)...

Having Issues Pushing Database Schema

Hi I am getting this issue whenever I am trying to push the database schema. Any help would be greatly appreciated. ``` ❯ pnpm drizzle-kit push:mysql --schema=./Database/schema.ts drizzle-kit: v0.19.13 drizzle-orm: v0.28.6...

migration failed

code: ```js const migrationClient = postgres("postgresql://jer:admin@localhost:5432/test", { max: 1 }) async function main() {...

TypeError: Cannot read properties of undefined (reading 'compositePrimaryKeys')

I am attempting to run db push, but I am getting this error above^^ does anyone know what might be going on?...

Nesting sqlite drizzle into a deeper location in my ts app, difficulties with src/ vs dist/

Hey! I'm very new to drizzle and trying to set up a very small drizzle instance for a service that reads a whole pile of json files and acts as a simple read-only information store. I got most of the setup to work. I have it at a location ``` src/...

syntax highlighting not working

I reinstalled the node_modules multiple times and it didnt fix my problem. This isnt suposed to look like this does it?
No description