Skip to content

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

Fix SecretVersionV2 reference issue blocking users and identities deletion

carlosmonastyrskiefb8b69777f7
diff --git a/backend/src/db/migrations/20250421165221_fix-identites-and-user-deletion-secret-version-reference.ts b/backend/src/db/migrations/20250421165221_fix-identites-and-user-deletion-secret-version-reference.ts
new file mode 100644
index 0000000000..f5280c979f
--- /dev/null
+++ b/backend/src/db/migrations/20250421165221_fix-identites-and-user-deletion-secret-version-reference.ts
@@ -0,0 +1,29 @@
+import { Knex } from "knex";
+
+import { TableName } from "@app/db/schemas";
+
+export async function up(knex: Knex): Promise<void> {
+ await knex.schema.alterTable(TableName.SecretVersionV2, (table) => {
+ table.dropForeign(["userActorId"]);
+ table.dropForeign(["identityActorId"]);
+ });
+
+ await knex.schema.alterTable(TableName.SecretVersionV2, (table) => {
+ table.foreign("userActorId").references("id").inTable(TableName.Users).onDelete("SET NULL");
+
+ table.foreign("identityActorId").references("id").inTable(TableName.Identity).onDelete("SET NULL");
+ });
+}
+
+export async function down(knex: Knex): Promise<void> {
+ await knex.schema.alterTable(TableName.SecretVersionV2, (table) => {
+ table.dropForeign(["userActorId"]);
+ table.dropForeign(["identityActorId"]);
+ });
+
+ await knex.schema.alterTable(TableName.SecretVersionV2, (table) => {
+ table.foreign("userActorId").references("id").inTable(TableName.Users);
+
+ table.foreign("identityActorId").references("id").inTable(TableName.Identity);
+ });
+}
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretDetailSidebar.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretDetailSidebar.tsx
index 6c9c549af3..c2d404ff6a 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretDetailSidebar.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretDetailSidebar.tsx
@@ -252,8 +252,12 @@ export const SecretDetailSidebar = ({
switch (userType) {
case ActorType.PLATFORM:
return "System-generated";
+ case ActorType.IDENTITY:
+ return userName || "Deleted Identity";
+ case ActorType.USER:
+ return userName || "Deleted User";
default:
- return userName;
+ return "Unknown";
}
};