Skip to content

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

migration: recreate delegated approval migration with the final schema

adilson3675c20052b4
diff --git a/backend/src/db/migrations/20261015145100_external-approvals.ts b/backend/src/db/migrations/20261027143736_delegated-approvals.ts
similarity index 82%
rename from backend/src/db/migrations/20261015145100_external-approvals.ts
rename to backend/src/db/migrations/20261027143736_delegated-approvals.ts
index 8c7a92b235..4eb14f421f 100644
--- a/backend/src/db/migrations/20261015145100_external-approvals.ts
+++ b/backend/src/db/migrations/20261027143736_delegated-approvals.ts
@@ -28,12 +28,18 @@ export async function up(knex: Knex): Promise<void> {
t.uuid("requestId").notNullable().unique();
t.foreign("requestId").references("id").inTable(TableName.ApprovalRequests).onDelete("CASCADE");
+ t.string("providerType", 50).notNullable();
t.string("status", 50).notNullable();
- t.binary("callbackTokenHash").nullable().unique();
- t.text("statusReason").nullable();
+ t.binary("encryptedCallbackToken").nullable();
+ t.jsonb("details").notNullable();
t.string("providerRequestId").nullable();
+ t.integer("callbackAttempts").notNullable().defaultTo(0);
+ t.timestamp("decisionReadRequestedAt", { useTz: true }).nullable();
+ t.uuid("dispatchEventId").notNullable();
t.timestamps(true, true, true);
+
+ t.unique(["providerRequestId", "providerType"]);
});
await createOnUpdateTrigger(knex, TableName.DelegatedApprovalRequests);
}
diff --git a/backend/src/db/schemas/delegated-approval-requests.ts b/backend/src/db/schemas/delegated-approval-requests.ts
index eb3d0ba28f..55ea94db33 100644
--- a/backend/src/db/schemas/delegated-approval-requests.ts
+++ b/backend/src/db/schemas/delegated-approval-requests.ts
@@ -12,10 +12,14 @@ import { TImmutableDBKeys } from "./models";
export const DelegatedApprovalRequestsSchema = z.object({
id: z.string().uuid(),
requestId: z.string().uuid(),
+ providerType: z.string(),
status: z.string(),
- callbackTokenHash: zodBuffer.nullable().optional(),
- statusReason: z.string().nullable().optional(),
+ encryptedCallbackToken: zodBuffer.nullable().optional(),
+ details: z.unknown(),
providerRequestId: z.string().nullable().optional(),
+ callbackAttempts: z.number().default(0),
+ decisionReadRequestedAt: z.date().nullable().optional(),
+ dispatchEventId: z.string().uuid(),
createdAt: z.date(),
updatedAt: z.date()
});