feat(housekeeping): add audit and preference storage

This commit is contained in:
Simo committed 2026-08-26 21:42:14 +02:00
1 parent bdb8f0b02b
commit 7c93d3e766
3 files changed
+175 -14

No files matched your search

+36 -14
View File
@@ -11,6 +11,7 @@ import {
datetime,
decimal,
double,
index,
int,
longtext,
mediumtext,
@@ -1149,21 +1150,42 @@ export const UserWatch = mysqlTable(
],
);
export const AdminAuditLog = mysqlTable("admin_audit_log", {
id: int("id").autoincrement().primaryKey().notNull(),
userId: int("user_id").notNull(),
action: varchar("action", { length: 191 }).notNull().default(""),
target: varchar("target", { length: 191 }).notNull().default(""),
targetId: int("target_id"),
details: text("details"),
before: text("before"),
after: text("after"),
diff: text("diff"),
ipAddress: varchar("ip_address", { length: 45 }),
createdAt: varchar("created_at", { length: 64 }).notNull().default(""),
updatedAt: varchar("updated_at", { length: 64 }),
});
export const AdminAuditLog = mysqlTable(
"admin_audit_log",
{
id: int("id").autoincrement().primaryKey().notNull(),
userId: int("user_id").notNull(),
action: varchar("action", { length: 191 }).notNull().default(""),
target: varchar("target", { length: 191 }).notNull().default(""),
targetId: int("target_id"),
details: text("details"),
before: text("before"),
after: text("after"),
diff: text("diff"),
ipAddress: varchar("ip_address", { length: 45 }),
correlationId: varchar("correlation_id", { length: 64 }),
outcome: varchar("outcome", { length: 32 }),
reason: text("reason"),
domain: varchar("domain", { length: 32 }),
createdAt: varchar("created_at", { length: 64 }).notNull().default(""),
updatedAt: varchar("updated_at", { length: 64 }),
},
(t) => [index("admin_audit_log_correlation_id_idx").on(t.correlationId)],
);
export const HousekeepingUserPreferences = mysqlTable(
"housekeeping_user_preferences",
{
userId: int("user_id").primaryKey().notNull(),
schemaVersion: int("schema_version").notNull().default(1),
payload: longtext("payload").notNull(),
createdAt: datetime("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
updatedAt: datetime("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`),
},
);
export type HousekeepingUserPreferenceRow =
typeof HousekeepingUserPreferences.$inferSelect;
export const AclRole = mysqlTable("acl_roles", {
id: int("id").autoincrement().primaryKey().notNull(),
slug: varchar("slug", { length: 191 }).unique().notNull(),