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 000000000..f5280c979 --- /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 { + 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 { + 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 6c9c549af..c2d404ff6 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"; } };