Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(pam): add selectedResourceId column to pam_sessions
bernie-gb83387c85f7f
diff --git a/backend/src/db/migrations/20260428141725_pam-session-selected-resource.ts b/backend/src/db/migrations/20260428141725_pam-session-selected-resource.tsnew file mode 100644index 0000000000..9c2516afcb--- /dev/null+++ b/backend/src/db/migrations/20260428141725_pam-session-selected-resource.ts@@ -0,0 +1,33 @@+import { Knex } from "knex";++import { TableName } from "../schemas";++// Domain accounts (e.g. Active Directory) are not parented to a specific resource — a+// single domain account can target any of the domain-linked resources. The existing+// `resourceId` column on pam_sessions is derived from `account.resourceId` and is null+// for these sessions. `selectedResourceId` records the specific resource the user+// picked at session-start time so reads can resolve a target via+// `selectedResourceId ?? resourceId`.+export async function up(knex: Knex): Promise<void> {+ if (await knex.schema.hasTable(TableName.PamSession)) {+ const hasCol = await knex.schema.hasColumn(TableName.PamSession, "selectedResourceId");+ if (!hasCol) {+ await knex.schema.alterTable(TableName.PamSession, (t) => {+ t.uuid("selectedResourceId").nullable().references("id").inTable(TableName.PamResource).onDelete("SET NULL");+ t.index("selectedResourceId");+ });+ }+ }+}++export async function down(knex: Knex): Promise<void> {+ if (await knex.schema.hasTable(TableName.PamSession)) {+ const hasCol = await knex.schema.hasColumn(TableName.PamSession, "selectedResourceId");+ if (hasCol) {+ await knex.schema.alterTable(TableName.PamSession, (t) => {+ t.dropIndex("selectedResourceId");+ t.dropColumn("selectedResourceId");+ });+ }+ }+}diff --git a/backend/src/db/schemas/pam-sessions.ts b/backend/src/db/schemas/pam-sessions.tsindex a3fc0d4ad4..cc3a57f7d3 100644--- a/backend/src/db/schemas/pam-sessions.ts+++ b/backend/src/db/schemas/pam-sessions.ts@@ -33,7 +33,8 @@ export const PamSessionsSchema = z.object({encryptedAiInsights: zodBuffer.nullable().optional(),aiInsightsStatus: z.string().nullable().optional(),aiInsightsError: z.string().nullable().optional(),- reason: z.string().nullable().optional()+ reason: z.string().nullable().optional(),+ selectedResourceId: z.string().uuid().nullable().optional()});export type TPamSessions = z.infer<typeof PamSessionsSchema>;