feat : add audit logs
CI / Verify (push) Successful in 1m28s
CI / Build immutable images and deploy (push) Successful in 2m40s

This commit is contained in:
2026-09-27 16:03:53 +07:00 Unverified
parent 094456ecba
commit 8ddb5896b6
18 changed files with 4027 additions and 115 deletions
+39
View File
@@ -177,6 +177,45 @@ export const outboxEvents = pgTable(
],
);
export const auditLogs = pgTable(
"audit_log",
{
id: bigint("id", { mode: "number" })
.primaryKey()
.generatedAlwaysAsIdentity(),
actorId: text("actor_id").notNull(),
actorLabel: text("actor_label").notNull(),
action: varchar("action", { length: 64 }).notNull(),
targetType: varchar("target_type", { length: 32 }).notNull(),
targetId: text("target_id").notNull(),
scope: varchar("scope", { length: 64 }),
resultingVersion: integer("resulting_version"),
metadata: jsonb("metadata")
.$type<Record<string, string | number | boolean | null>>()
.default({})
.notNull(),
createdAt: timestamp("created_at", { withTimezone: true })
.defaultNow()
.notNull(),
},
(table) => [
index("audit_log_created_idx").on(table.createdAt, table.id),
index("audit_log_actor_created_idx").on(
table.actorId,
table.createdAt,
),
index("audit_log_target_created_idx").on(
table.targetType,
table.targetId,
table.createdAt,
),
index("audit_log_action_created_idx").on(
table.action,
table.createdAt,
),
],
);
export const catalogCharacters = catalogSchema.table(
"character",
{