perf(db): 审计按时间倒序索引(迁移 0088)
日志接口审计来源按时间倒序取前 n 条,原有索引都不以 at 开头。 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
2bd09c89e9
commit
14cb2c4c7e
1 file changed
+17
@@ -0,0 +1,17 @@
|
||||
import type { Kysely } from "kysely";
|
||||
import { execDdl } from "../src/migration-helpers.ts";
|
||||
|
||||
// 日志接口:审计来源按时间倒序取前 n 条,原有索引都以 action / actor / target 开头,只能整表排序;
|
||||
// 补一个按时间的索引(审计会随登录、设置修改一直增长)。
|
||||
// 引擎表 openworkflow.workflow_runs 不在这里加索引:引擎自带 (namespace_id, created_at desc) 与
|
||||
// (namespace_id, status, created_at desc),日志查询已能沿用。
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: 迁移不依赖应用表类型
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await execDdl(db, `create index if not exists audit_event_at_idx on audit_event (at desc);`);
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: 同上
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await execDdl(db, `drop index if exists audit_event_at_idx;`);
|
||||
}
|
||||
Reference in new issue
Block a user