DT
Drizzle Team12mo ago
nk

Recursive category/subcategories, can't infer relation

Any help?
No description
4 Replies
nk
nkOP12mo ago
It might just be a better idea to make a subcategory table specifically IMO As in this case you could easily delete a category and have a null subcategory, since you can't put a notNull on it
rbravo
rbravo12mo ago
Yeah, this is exactly my use case where I'm also seeing the error. And btw, this case that you described: "you could easily delete a category and have a null subcategory, since you can't put a notNull on it". Could be fixed with onDelete: 'cascade'. https://www.answeroverflow.com/m/1110915016959475743 IMO your initial relation is ok and should work without "workarounds"
How to delete with cascade? - Drizzle Team
I'm using postgres with the following schema (reduced to the important parts): ``` export const worlds = pgTable('worlds', { id: uuid('id').defaultRandom().primaryKey() }) export const users_to_worlds = pgTable( 'users_to_worlds', { userId: varchar('user_id', { length: 32 }) .references(() => users.id) .notNull(), worl...
nk
nkOP12mo ago
I fixed it by setting the relationName on category and subcategories to be the same
Want results from more Discord servers?
Add your server