♻️ prevent deleting resource policies if they have attached resources

This commit is contained in:
Fred KISSIE
2026-03-07 01:12:10 +01:00
parent 884482ec35
commit f8e18de2fc
3 changed files with 44 additions and 18 deletions

View File

@@ -102,6 +102,12 @@ export const resources = pgTable("resources", {
() => resourcePolicies.resourcePolicyId,
{ onDelete: "set null" }
),
defaultResourcePolicyId: integer("defaultResourcePolicyId").references(
() => resourcePolicies.resourcePolicyId,
{
onDelete: "restrict"
}
),
resourceGuid: varchar("resourceGuid", { length: 36 })
.unique()
.notNull()