Skip to content

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

feat: patched up migration to support pg14

=af5e22f562f1
diff --git a/backend/src/db/migrations/20251018061215_sub-org.ts b/backend/src/db/migrations/20251018061215_sub-org.ts
index bd577fe752..d048a23d32 100644
--- a/backend/src/db/migrations/20251018061215_sub-org.ts
+++ b/backend/src/db/migrations/20251018061215_sub-org.ts
@@ -14,14 +14,10 @@ export async function up(knex: Knex): Promise<void> {
t.foreign("rootOrgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");
t.dropUnique(["slug"]);
+ t.unique(["rootOrgId", "parentOrgId", "slug"]);
});
// had to switch to raw for null not distinct
- await knex.raw(`
-ALTER TABLE "organization"
-ADD CONSTRAINT "organization_root_parent_slug_unique"
-UNIQUE ("rootOrgId", "parentOrgId", "slug") NULLS NOT DISTINCT;
-`);
}
const hasIdentityOrgCol = await knex.schema.hasColumn(TableName.Identity, "orgId");
diff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.ts
index 6334322eb9..265612d557 100644
--- a/backend/src/services/org/org-service.ts
+++ b/backend/src/services/org/org-service.ts
@@ -516,6 +516,12 @@ export const orgServiceFactory = ({
}
}
+ if (slug) {
+ const existingOrg = await orgDAL.findOne({ slug, rootOrgId: null });
+ if (existingOrg && existingOrg?.id !== orgId)
+ throw new BadRequestError({ message: `Organization with slug ${slug} already exist` });
+ }
+
if (googleSsoAuthEnforced) {
if (googleSsoAuthEnforced && currentOrg.authEnforced) {
throw new BadRequestError({