4 Replies
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
I think this is the same issue https://discord.com/channels/1043890932593987624/1198007634473799811
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...
I fixed it by setting the relationName on category and subcategories to be the same