Can't create relation between two tables

I'm trying to create a relation between a clients table and a sheets tables where a client can have multiple sheets linked to their ID, but I keep getting complaints about incompatible foreign keys due to my bad schema Fixed; for anyone wondering, instead of using references(() => clients.id) very shallowly you have to create proper relations like such:
export const clientsRelations = relations(clients, (({ many }) => ({
sheets: many(sheets),
})))

export const sheetsRelations = relations(sheets, (({ one }) => ({
client: one(clients, {
fields: [sheets.client_id],
references: [clients.id],
})
})))
export const clientsRelations = relations(clients, (({ many }) => ({
sheets: many(sheets),
})))

export const sheetsRelations = relations(sheets, (({ one }) => ({
client: one(clients, {
fields: [sheets.client_id],
references: [clients.id],
})
})))
ù
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server