feat(housekeeping): add audit and preference storage
This commit is contained in:
1 parent
bdb8f0b02b
commit
7c93d3e766
3 files changed
+163
-2
No files matched your search
@@ -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`)
|
||||||
|
);
|
||||||
+24
-2
@@ -11,6 +11,7 @@ import {
|
|||||||
datetime,
|
datetime,
|
||||||
decimal,
|
decimal,
|
||||||
double,
|
double,
|
||||||
|
index,
|
||||||
int,
|
int,
|
||||||
longtext,
|
longtext,
|
||||||
mediumtext,
|
mediumtext,
|
||||||
@@ -1149,7 +1150,9 @@ export const UserWatch = mysqlTable(
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
export const AdminAuditLog = mysqlTable("admin_audit_log", {
|
export const AdminAuditLog = mysqlTable(
|
||||||
|
"admin_audit_log",
|
||||||
|
{
|
||||||
id: int("id").autoincrement().primaryKey().notNull(),
|
id: int("id").autoincrement().primaryKey().notNull(),
|
||||||
userId: int("user_id").notNull(),
|
userId: int("user_id").notNull(),
|
||||||
action: varchar("action", { length: 191 }).notNull().default(""),
|
action: varchar("action", { length: 191 }).notNull().default(""),
|
||||||
@@ -1160,10 +1163,29 @@ export const AdminAuditLog = mysqlTable("admin_audit_log", {
|
|||||||
after: text("after"),
|
after: text("after"),
|
||||||
diff: text("diff"),
|
diff: text("diff"),
|
||||||
ipAddress: varchar("ip_address", { length: 45 }),
|
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(""),
|
createdAt: varchar("created_at", { length: 64 }).notNull().default(""),
|
||||||
updatedAt: varchar("updated_at", { length: 64 }),
|
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
Reference in new issue
Block a user