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
improvements: address feedback
Scott Wilson42e9bfaf8c58
diff --git a/backend/src/db/migrations/20260317200000_membership-unique-constraints.ts b/backend/src/db/migrations/20260317200000_membership-unique-constraints.tsindex a407d00f58..2fb9f69ed2 100644--- a/backend/src/db/migrations/20260317200000_membership-unique-constraints.ts+++ b/backend/src/db/migrations/20260317200000_membership-unique-constraints.ts@@ -63,21 +63,25 @@ const deduplicateProjectMemberships = async (for (const { keeper, duplicateIds, actorId, scopeId } of groups) {// Get existing roles on the keeper so we can skip true duplicates// eslint-disable-next-line no-await-in-loop- const keeperRoles: { role: string; customRoleId: string | null }[] = await tx(TableName.MembershipRole)+ const keeperRoles: { role: string; customRoleId: string | null; isTemporary: boolean }[] = await tx(+ TableName.MembershipRole+ ).where({ membershipId: keeper.id })- .select("role", "customRoleId");+ .select("role", "customRoleId", "isTemporary");- const keeperRoleKeys = new Set(keeperRoles.map((r) => `${r.role}:${r.customRoleId ?? ""}`));+ const keeperRoleKeys = new Set(keeperRoles.map((r) => `${r.role}:${r.customRoleId ?? ""}:${r.isTemporary}`));// Find roles on duplicates that don't already exist on the keeper// eslint-disable-next-line no-await-in-loop- const duplicateRoles: { id: string; role: string; customRoleId: string | null }[] = await tx(+ const duplicateRoles: { id: string; role: string; customRoleId: string | null; isTemporary: boolean }[] = await tx(TableName.MembershipRole).whereIn("membershipId", duplicateIds)- .select("id", "role", "customRoleId");+ .select("id", "role", "customRoleId", "isTemporary");- const rolesToReparent = duplicateRoles.filter((r) => !keeperRoleKeys.has(`${r.role}:${r.customRoleId ?? ""}`));+ const rolesToReparent = duplicateRoles.filter(+ (r) => !keeperRoleKeys.has(`${r.role}:${r.customRoleId ?? ""}:${r.isTemporary}`)+ );if (rolesToReparent.length > 0) {// eslint-disable-next-line no-await-in-loop@@ -142,34 +146,34 @@ export async function up(knex: Knex): Promise<void> {// Project scopeawait knex.schema.raw(`- CREATE UNIQUE INDEX membership_unique_user_project+ CREATE UNIQUE INDEX IF NOT EXISTS membership_unique_user_projectON ${TableName.Membership} ("scopeProjectId", "actorUserId")WHERE scope = 'project' AND "actorUserId" IS NOT NULL;`);await knex.schema.raw(`- CREATE UNIQUE INDEX membership_unique_identity_project+ CREATE UNIQUE INDEX IF NOT EXISTS membership_unique_identity_projectON ${TableName.Membership} ("scopeProjectId", "actorIdentityId")WHERE scope = 'project' AND "actorIdentityId" IS NOT NULL;`);await knex.schema.raw(`- CREATE UNIQUE INDEX membership_unique_group_project+ CREATE UNIQUE INDEX IF NOT EXISTS membership_unique_group_projectON ${TableName.Membership} ("scopeProjectId", "actorGroupId")WHERE scope = 'project' AND "actorGroupId" IS NOT NULL;`);// Org scopeawait knex.schema.raw(`- CREATE UNIQUE INDEX membership_unique_user_org+ CREATE UNIQUE INDEX IF NOT EXISTS membership_unique_user_orgON ${TableName.Membership} ("scopeOrgId", "actorUserId")WHERE scope = 'organization' AND "actorUserId" IS NOT NULL;`);await knex.schema.raw(`- CREATE UNIQUE INDEX membership_unique_identity_org+ CREATE UNIQUE INDEX IF NOT EXISTS membership_unique_identity_orgON ${TableName.Membership} ("scopeOrgId", "actorIdentityId")WHERE scope = 'organization' AND "actorIdentityId" IS NOT NULL;`);await knex.schema.raw(`- CREATE UNIQUE INDEX membership_unique_group_org+ CREATE UNIQUE INDEX IF NOT EXISTS membership_unique_group_orgON ${TableName.Membership} ("scopeOrgId", "actorGroupId")WHERE scope = 'organization' AND "actorGroupId" IS NOT NULL;`);