unit(D8): audit_log table + migration + audit-row builder (rule 12)
This commit is contained in:
@@ -295,6 +295,30 @@ export const assignments = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
/* ----------------------------------------------------------- audit log (D8) */
|
||||
|
||||
/**
|
||||
* Append-only audit trail (ARCHITECTURE §638, BUILD-SPEC §7 rule 12).
|
||||
* Every admin mutation writes one row here; the app never updates or deletes
|
||||
* a row. `before_json` / `after_json` capture the before/after of the change
|
||||
* (empty string when there is none); `created_at` is a UTC instant.
|
||||
*/
|
||||
export const auditLog = pgTable("audit_log", {
|
||||
id: text("id").primaryKey(),
|
||||
actorId: text("actor_id").notNull(),
|
||||
actorIpHash: text("actor_ip_hash"),
|
||||
action: text("action").notNull(),
|
||||
entityType: text("entity_type").notNull(),
|
||||
entityId: text("entity_id"),
|
||||
beforeJson: text("before_json").notNull().default(""),
|
||||
afterJson: text("after_json").notNull().default(""),
|
||||
createdAt: timestamp("created_at", { mode: "date", withTimezone: true })
|
||||
.notNull()
|
||||
.defaultNow(),
|
||||
},
|
||||
(table) => [index("audit_log_created_idx").on(table.createdAt)],
|
||||
);
|
||||
|
||||
/* ------------------------------------------------- unavailability (D4) */
|
||||
|
||||
/**
|
||||
@@ -736,6 +760,7 @@ export const schema = {
|
||||
serviceInstances,
|
||||
slots,
|
||||
assignments,
|
||||
auditLog,
|
||||
unavailability,
|
||||
skillCategories,
|
||||
vendors,
|
||||
|
||||
Reference in New Issue
Block a user