Drizzle Team

DT

Drizzle Team

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

Join
flo_08
flo_085/14/2024

base generic repository

Hey guys! I'm really struggling to create a base crud repository which i can use as a base class for all of my entities. has anyone a working code for this? would be glad for any help
JP
JP5/14/2024

one-to-many self reference

Hello guys, this is a simplified section of my schema: ``` typescript export const contacts = mysqlTable("contacts", { id: int("id").primaryKey(),...
Wiznet
Wiznet5/14/2024

Enforcing DB level foreign keys

Hey guys, I've read the docs on the relation key word and the docs note that the relations are only on the application level. How can we create foreign key relations via the schema that are enforced on the DB level?
John
John5/14/2024

Nested SQL select returning [x: string]: unknown type

This may also be delving into SQL-specific questions, but I have a complex query where I'm joining ten tables and at points, the select object is nested three deep. (I'm fairly intermediate to SQL so if I'm thinking about this wrong, please tell me). I can get the query pretty close using the query builder syntax but I have to do some specific where/orderby selects that throw errors for some reason. No problem, I rewrite it in the db.select() syntax and it is now correctly returning data. However, the return type is just: {...
Tungdayhehe
Tungdayhehe5/14/2024

drizzle-graphql - buildSchema doesn't support `ApolloFederationDriver`

Context I'm building a NestJS microservice application with GraphQL using ApolloFederationDriver. Its main components is: 1) A GQL federation gateway: as super-graph (left-handed side in the code snippet image) and this will connect to distributed schema in other subgraph microservices 2) Subgraph microservices: this will hold actuall schema of GQL in each microservice (mid and right-handed side) the GQL schema will be generated from drizzle buildSchema function....
No description
Erik the Red
Erik the Red5/14/2024

Fetching id from recently inserted data

Does Drizzle return the insertId if it is a UUID or a nanoid, and not a number, if not how do I get the inserted id. await ctx.db .update(homeTable) .set({ isAlive: true })...
ajdorro Pirate
ajdorro Pirate5/14/2024

Subquery in Delete

what is the correct way to write a delete statement with a subquery? example not working: ```...
fantasy
fantasy5/14/2024

uuid becomes text in migration

In my schema i have a user table (based on auth.js requirements): ```ts export const users = pgTable("user", { id: uuid("id").primaryKey().defaultRandom(), name: text("name"),...
megamindat
megamindat5/13/2024

Not enough information to infer relation

I've defined these relation between section and item, and I'm getting "Error: There is not enough information to infer relation "public.section.item"
No description
Senna
Senna5/13/2024

Soft delete

Hey, is there a soft delete option in Drizzle, that sets a deletedAt column instead of removing the record? In Sequelize it's called paranoid-option. Thanks!...
2armedlopin
2armedlopin5/13/2024

After this new update I am getting an introspection error schema below "drizzle-kit": "^0.21.1",

Error: There is not enough information to infer relation "public.users.twoFactorConfirmation"
export const usersRelations = relations(users, ({ one }) => ({
twoFactorConfirmation: one(twoFactorConfirmation),
}))
export const usersRelations = relations(users, ({ one }) => ({
twoFactorConfirmation: one(twoFactorConfirmation),
}))
...
Gautam Vaishnav
Gautam Vaishnav5/13/2024

Failed to load external module node:stream: TypeError: Native module not found: node:stream

Failed to load external module node:stream: TypeError: Native module not found: node:stream getting this error while using drizzle adapter with authjs...
No description
Aryxst
Aryxst5/13/2024

Setting default timestamp in user table

So Im using turso with sqlite and out of nowhere i have been issuing this issue with my user table, im using nextauthjs ```tsx import { sql } from 'drizzle-orm'; import { sqliteTable, text, primaryKey, integer, int } from 'drizzle-orm/sqlite-core';...
Stu
Stu5/13/2024

Reverse Migration

Hey, Is Drizzle working on the ability to reverse a migration? https://github.com/drizzle-team/drizzle-orm/discussions/1339 I'm looking at using drizzle in our production app, but without reverse migrations we will need to build some extra release process likely with Flywheel or something that I can pump in the migration script and create a down/reverse migration script. Before diving into this, I thought I'd check if this is something in the roadmap or coming soon to avoid creating wheels 🙂...
Jamil Hossain
Jamil Hossain5/13/2024

Schema changes not detecting with sqlite

Im using sqlite with drizzle orm, in the schema i have one table. i generated migration files from it. But when i added a new column in the existing table and tried to generate a new migration it says "No schema changes, nothing to migrate" even though i did add a new column in the table. and it's only happening with sqlite. But if i use postgres then it works just fine.
Teapot
Teapot5/13/2024

Fix mismatched schema and migration files.

Hello! I am new here, so please ignore some of my stupid remarks. The point is that I was wondering if we can fix the malformed migration files that causes from manually deleted or corrupted migration out folder.
Slaven
Slaven5/13/2024

Table definition to TS type

Is it possible to get a TS type from a Drizzle Schema Table definition? Something like this: ```ts export const users = pgTable('user', { id: text('id')...
rubberduckies
rubberduckies5/13/2024

magic sql column naming

Ok, here's a doozy: One of the things i like best about drizzle vs prisma is the fact that we can keep the standard naming conventions at the database level and still get the objects with cool camelCase properties. For example: ``` export const Purchases = pgTable('purchases', {...
jaslr
jaslr5/13/2024

Should drizzle-kit introspect produce the same content as my existing schema?

In my sveltekit app /lib/server/schema.ts is my schema, changes are made and then drizzle-kit push pushed to my prod server. If I run a drizzle-kit introspect should this pulled schema == my /lib/server/schema.ts? I was under the impression it would be, and that it was prior to 0.21.0 upgrade but I could 100% be mistaken....