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

+17
View File
@@ -0,0 +1,17 @@
-- Housekeeping audit correlation and user presentation preferences.
-- Additive only: this shared schema is also consumed by the emulator.
ALTER TABLE `admin_audit_log`
ADD COLUMN `correlation_id` VARCHAR(64) NULL,
ADD COLUMN `outcome` VARCHAR(32) NULL,
ADD COLUMN `reason` TEXT NULL,
ADD COLUMN `domain` VARCHAR(32) NULL,
ADD INDEX `admin_audit_log_correlation_id_idx` (`correlation_id`);
CREATE TABLE `housekeeping_user_preferences` (
`user_id` INT NOT NULL,
`schema_version` INT NOT NULL DEFAULT 1,
`payload` LONGTEXT NOT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`user_id`)
);
+36 -14
View File
@@ -11,6 +11,7 @@ import {
datetime, datetime,
decimal, decimal,
double, double,
index,
int, int,
longtext, longtext,
mediumtext, mediumtext,
@@ -1149,21 +1150,42 @@ export const UserWatch = mysqlTable(
], ],
); );
export const AdminAuditLog = mysqlTable("admin_audit_log", { export const AdminAuditLog = mysqlTable(
id: int("id").autoincrement().primaryKey().notNull(), "admin_audit_log",
userId: int("user_id").notNull(), {
action: varchar("action", { length: 191 }).notNull().default(""), id: int("id").autoincrement().primaryKey().notNull(),
target: varchar("target", { length: 191 }).notNull().default(""), userId: int("user_id").notNull(),
targetId: int("target_id"), action: varchar("action", { length: 191 }).notNull().default(""),
details: text("details"), target: varchar("target", { length: 191 }).notNull().default(""),
before: text("before"), targetId: int("target_id"),
after: text("after"), details: text("details"),
diff: text("diff"), before: text("before"),
ipAddress: varchar("ip_address", { length: 45 }), after: text("after"),
createdAt: varchar("created_at", { length: 64 }).notNull().default(""), diff: text("diff"),
updatedAt: varchar("updated_at", { length: 64 }), 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", { export const AclRole = mysqlTable("acl_roles", {
id: int("id").autoincrement().primaryKey().notNull(), id: int("id").autoincrement().primaryKey().notNull(),
slug: varchar("slug", { length: 191 }).unique().notNull(), slug: varchar("slug", { length: 191 }).unique().notNull(),
File diff suppressed because it is too large. Load diff