Skip to content

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

capture pam orgs before backfill

x03220509e41a49acd6
diff --git a/backend/src/db/migrations/20260603030053_pam-revamp.ts b/backend/src/db/migrations/20260603030053_pam-revamp.ts
index 1cc20749e3..907b0a8826 100644
--- a/backend/src/db/migrations/20260603030053_pam-revamp.ts
+++ b/backend/src/db/migrations/20260603030053_pam-revamp.ts
@@ -110,6 +110,9 @@ export async function up(knex: Knex): Promise<void> {
await createOnUpdateTrigger(knex, TableName.PamAccountTemplate);
+ // Capture orgs that have a PAM project before backfill
+ const orgsWithPam = await knex(TableName.Project).where("type", ProjectType.PAM).distinct("orgId").select("orgId");
+
await backfillPamProjectsForAllOrgs(knex);
// Drop old folders table and recreate with new schema
@@ -187,8 +190,6 @@ export async function up(knex: Knex): Promise<void> {
const getProjectCipher = async (projectId: string) =>
kmsService.createCipherPairWithDataKey({ type: KmsDataKey.SecretManager, projectId }, knex);
- const orgsWithPam = await knex(TableName.Project).where("type", ProjectType.PAM).distinct("orgId").select("orgId");
-
for (const { orgId } of orgsWithPam) {
const org = await knex(TableName.Organization).where("id", orgId).first("defaultPamProjectId");
const newProjectId = org!.defaultPamProjectId as string;