One-to-Many Self relation, Not enough information to infer relation

Im currently working on a piece of software for infrastructure management. This software contains so-called "controls" that need to be done periodically. Every control can be followed up by multiple controls (called follow up control). But each control can only have one parent control it follows up on.

I have created the following schema:
// controls Table
export const controls = pgTable("controls", {
    id: serial("id").primaryKey().notNull(),
    passed: boolean("passed").notNull().default(false),
    user_id: bigint("user_id", { mode: 'number' }).references(() => users.id, {onUpdate: 'cascade', onDelete: 'restrict'}).notNull(),
    followUpForControl_id: bigint("followUpForControl_id", { mode: 'number' }).references((): AnyPgColumn => controls.id, {onUpdate: 'cascade', onDelete: 'restrict'}),
});

export const controlRelations = relations(controls, ({ one, many }) => ({
    user: one(users, {
        fields: [controls.user_id],
        references: [users.id]
    }),
    followUpControls: many(controls, {
        relationName: 'followUpControls'
    }),
    followUpForControl: one(controls, {
        fields: [controls.followUpForControl_id],
        references: [controls.id],
        relationName: 'followUpForControl'
    }),
}));


However when i try to query with followUpControls i get "There is not enough information to infer relation "controls.followUpControls""
Was this page helpful?