Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Update 20260629120000_create-audit-reports.ts

varonix0092244b3bfc9
diff --git a/backend/src/db/migrations/20260629120000_create-audit-reports.ts b/backend/src/db/migrations/20260629120000_create-audit-reports.ts
index 3ed75ff852..b5836df553 100644
--- a/backend/src/db/migrations/20260629120000_create-audit-reports.ts
+++ b/backend/src/db/migrations/20260629120000_create-audit-reports.ts
@@ -2,6 +2,7 @@ import { Knex } from "knex";
import { TableName } from "@app/db/schemas";
import { createOnUpdateTrigger, dropOnUpdateTrigger } from "@app/db/utils";
+import { AuditReportStatus } from "@app/ee/services/audit-report/audit-report-types";
export async function up(knex: Knex): Promise<void> {
if (!(await knex.schema.hasTable(TableName.AuditReport))) {
@@ -9,19 +10,17 @@ export async function up(knex: Knex): Promise<void> {
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
t.string("projectId").notNullable();
t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE");
- // The requester is retained for history/audit; null it out (rather than cascade-delete the
- // report row) when the user is removed so the audit trail survives.
+
t.uuid("requestedByUserId");
t.foreign("requestedByUserId").references("id").inTable(TableName.Users).onDelete("SET NULL");
- t.string("status").notNullable().defaultTo("pending");
- // [{ type, inputs }, ...] — the report types requested in this batch.
+
+ t.string("status").notNullable().defaultTo(AuditReportStatus.Pending);
t.jsonb("reportConfigs").notNullable();
t.specificType("emailRecipients", "text[]").notNullable();
- // [{ type, rowCount, truncated }, ...] — populated by the generation worker on success.
t.jsonb("resultSummary");
t.text("errorMessage");
t.timestamps(true, true, true);
- // FK indexes — Postgres does not auto-index FK columns.
+
t.index(["projectId"]);
t.index(["requestedByUserId"]);
});