I'm trying to launch drizzle studio but I get the following error :
Error: There is not enough information to infer relation "restaurantsTable.categories"
What have I done wrong ?
schema.ts
export const restaurantsTable = pgTable("restaurants", {
id: serial("id").primaryKey(),
[...]
});
export const restaurantTableRelations = relations(restaurantsTable, ({ one, many }) => ({
menu: many(menuTable),
categories: many(categoryTable, { relationName: 'categories' }),
}));
export const categoryTable = pgTable("categories", {
id: serial("id").primaryKey(),
restaurant_id: integer('restaurant_id').notNull()
});
export const categoryTableRelations = relations(categoryTable, ({ one }) => ({
menu: one(menuTable, {
fields: [categoryTable.restaurant_id],
references: [menuTable.id],
relationName: 'menu'
})
}));
Faced the same issue, turns out they're strict on defining the relationName on both sides as mentioned in here
Ensuring it's defined on both sides solved my issue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With