// 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'
}),
}));
// 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'
}),
}));