Skip to content

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

feat(secret-value-tracking): add the org-wide tracking flag

Calvin7af70eb8f007
diff --git a/backend/src/db/migrations/20260924120000_add-org-wide-secret-value-tracking.ts b/backend/src/db/migrations/20260924120000_add-org-wide-secret-value-tracking.ts
new file mode 100644
index 0000000000..405426036f
--- /dev/null
+++ b/backend/src/db/migrations/20260924120000_add-org-wide-secret-value-tracking.ts
@@ -0,0 +1,33 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+export async function up(knex: Knex): Promise<void> {
+ if (await knex.schema.hasTable(TableName.Organization)) {
+ const hasColumn = await knex.schema.hasColumn(TableName.Organization, "orgWideSecretValueTrackingEnabled");
+ if (!hasColumn) {
+ await knex.schema.alterTable(TableName.Organization, (t) => {
+ t.boolean("orgWideSecretValueTrackingEnabled").defaultTo(true).notNullable();
+ });
+
+ // Organizations that already exist hold secrets written before the org-scoped digest, so they
+ // are incomplete until their backfill runs. Only organizations created from here on carry it
+ // on every secret they ever write.
+ //
+ // Raw rather than a typed update: the generated schema is regenerated from the database this
+ // migration has not yet been applied to, so a typed update cannot compile when it first runs.
+ await knex.raw(`UPDATE ?? SET "orgWideSecretValueTrackingEnabled" = false`, [TableName.Organization]);
+ }
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ if (await knex.schema.hasTable(TableName.Organization)) {
+ const hasColumn = await knex.schema.hasColumn(TableName.Organization, "orgWideSecretValueTrackingEnabled");
+ if (hasColumn) {
+ await knex.schema.alterTable(TableName.Organization, (t) => {
+ t.dropColumn("orgWideSecretValueTrackingEnabled");
+ });
+ }
+ }
+}
diff --git a/backend/src/db/schemas/organizations.ts b/backend/src/db/schemas/organizations.ts
index 54afbf3beb..b49095b1a9 100644
--- a/backend/src/db/schemas/organizations.ts
+++ b/backend/src/db/schemas/organizations.ts
@@ -43,7 +43,8 @@ export const OrganizationsSchema = z.object({
blockDuplicateSecretSyncDestinations: z.boolean().default(false),
secretShareBrandConfig: z.unknown().nullable().optional(),
defaultCertManagerProjectId: z.string().nullable().optional(),
- allowCrossProjectSecretSharing: z.boolean().default(false)
+ allowCrossProjectSecretSharing: z.boolean().default(false),
+ orgWideSecretValueTrackingEnabled: z.boolean().default(true)
});
export type TOrganizations = z.infer<typeof OrganizationsSchema>;