Skip to content

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

pam: fold run dependency-count columns into the new migration

bernie-g22a5c4be3057
diff --git a/backend/src/db/migrations/20260701000000_pam-discovery.ts b/backend/src/db/migrations/20260701000000_pam-discovery.ts
index c7eac4f331..3e36ce895d 100644
--- a/backend/src/db/migrations/20260701000000_pam-discovery.ts
+++ b/backend/src/db/migrations/20260701000000_pam-discovery.ts
@@ -50,9 +50,6 @@ export async function up(knex: Knex): Promise<void> {
t.string("triggeredBy").notNullable();
t.integer("discoveredCount").notNullable().defaultTo(0);
t.integer("newCount").notNullable().defaultTo(0);
- // Nullable: a scan that did not run dependency discovery leaves these null so the summary can omit deps.
- t.integer("dependencyCount");
- t.integer("newDependencyCount");
t.text("errorMessage");
t.jsonb("machineErrors");
t.timestamp("startedAt");
diff --git a/backend/src/db/migrations/20260720183403_pam-account-dependencies-rework.ts b/backend/src/db/migrations/20260720183403_pam-account-dependencies-rework.ts
index 80f14b4798..fa58be78b2 100644
--- a/backend/src/db/migrations/20260720183403_pam-account-dependencies-rework.ts
+++ b/backend/src/db/migrations/20260720183403_pam-account-dependencies-rework.ts
@@ -45,9 +45,26 @@ export async function up(knex: Knex): Promise<void> {
);
await createOnUpdateTrigger(knex, TableName.PamAccountDependency);
+
+ // The discovery run summary reports dependency counts alongside account counts. The runs table already
+ // exists (created by the prior pam-discovery migration), so add the columns here, nullable, so a scan that
+ // did not run dependency discovery leaves them null and the summary can omit the dependencies clause.
+ if (!(await knex.schema.hasColumn(TableName.PamDiscoverySourceRun, "dependencyCount"))) {
+ await knex.schema.alterTable(TableName.PamDiscoverySourceRun, (t) => {
+ t.integer("dependencyCount");
+ t.integer("newDependencyCount");
+ });
+ }
}
export async function down(knex: Knex): Promise<void> {
+ if (await knex.schema.hasColumn(TableName.PamDiscoverySourceRun, "dependencyCount")) {
+ await knex.schema.alterTable(TableName.PamDiscoverySourceRun, (t) => {
+ t.dropColumn("dependencyCount");
+ t.dropColumn("newDependencyCount");
+ });
+ }
+
await dropOnUpdateTrigger(knex, TableName.PamAccountDependency);
await knex.schema.dropTableIfExists(TableName.PamAccountDependency);