feat(db): add deletedAt audit timestamp to soft-deletable models
Add deletedAt DateTime? to User, Client, Role, Resource, and Blueprint models for GDPR-compliant deactivation audit trail. Soft-delete mutations now stamp deletedAt: new Date() on deactivation and clear it on reactivation. Migration and test assertions updated accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -135,14 +135,18 @@ describe("blueprint procedure support", () => {
|
||||
);
|
||||
|
||||
expect($transaction).toHaveBeenCalledTimes(1);
|
||||
expect(update).toHaveBeenNthCalledWith(1, {
|
||||
where: { id: "bp_1" },
|
||||
data: { isActive: false },
|
||||
});
|
||||
expect(update).toHaveBeenNthCalledWith(2, {
|
||||
where: { id: "bp_2" },
|
||||
data: { isActive: false },
|
||||
});
|
||||
expect(update).toHaveBeenNthCalledWith(1,
|
||||
expect.objectContaining({
|
||||
where: { id: "bp_1" },
|
||||
data: expect.objectContaining({ isActive: false }),
|
||||
}),
|
||||
);
|
||||
expect(update).toHaveBeenNthCalledWith(2,
|
||||
expect.objectContaining({
|
||||
where: { id: "bp_2" },
|
||||
data: expect.objectContaining({ isActive: false }),
|
||||
}),
|
||||
);
|
||||
expect(createAuditEntry).toHaveBeenCalledTimes(2);
|
||||
expect(result).toEqual({ count: 2 });
|
||||
});
|
||||
|
||||
@@ -227,14 +227,18 @@ describe("blueprint router", () => {
|
||||
const result = await caller.batchDelete({ ids: ["bp_1", "bp_2"] });
|
||||
|
||||
expect(transaction).toHaveBeenCalledTimes(1);
|
||||
expect(update).toHaveBeenNthCalledWith(1, {
|
||||
where: { id: "bp_1" },
|
||||
data: { isActive: false },
|
||||
});
|
||||
expect(update).toHaveBeenNthCalledWith(2, {
|
||||
where: { id: "bp_2" },
|
||||
data: { isActive: false },
|
||||
});
|
||||
expect(update).toHaveBeenNthCalledWith(1,
|
||||
expect.objectContaining({
|
||||
where: { id: "bp_1" },
|
||||
data: expect.objectContaining({ isActive: false }),
|
||||
}),
|
||||
);
|
||||
expect(update).toHaveBeenNthCalledWith(2,
|
||||
expect.objectContaining({
|
||||
where: { id: "bp_2" },
|
||||
data: expect.objectContaining({ isActive: false }),
|
||||
}),
|
||||
);
|
||||
expect(auditCreate).toHaveBeenCalledTimes(2);
|
||||
expect(result).toEqual({ count: 2 });
|
||||
});
|
||||
|
||||
@@ -460,7 +460,7 @@ describe("resource router CRUD", () => {
|
||||
expect(db.resource.update).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
where: { id: "res_1" },
|
||||
data: { isActive: false },
|
||||
data: expect.objectContaining({ isActive: false }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user