Feat: role applicability controls (#14239)

Closes [#1404](https://github.com/twentyhq/core-team-issues/issues/1404)

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
Abdul Rahman
2025-09-04 08:58:50 +05:30
committed by GitHub
parent 052f91cff1
commit 79bcd90d8d
72 changed files with 1889 additions and 344 deletions
@@ -0,0 +1,35 @@
import { type MigrationInterface, type QueryRunner } from 'typeorm';
export class AddRoleApplicabilityFields1756434280823
implements MigrationInterface
{
name = 'AddRoleApplicabilityFields1756434280823';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "core"."role" ADD "canBeAssignedToUsers" boolean NOT NULL DEFAULT true`,
);
await queryRunner.query(
`ALTER TABLE "core"."role" ADD "canBeAssignedToAgents" boolean NOT NULL DEFAULT true`,
);
await queryRunner.query(
`ALTER TABLE "core"."role" ADD "canBeAssignedToApiKeys" boolean NOT NULL DEFAULT true`,
);
await queryRunner.query(
`UPDATE "core"."role" SET "canBeAssignedToUsers" = true, "canBeAssignedToAgents" = true, "canBeAssignedToApiKeys" = true`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "core"."role" DROP COLUMN "canBeAssignedToApiKeys"`,
);
await queryRunner.query(
`ALTER TABLE "core"."role" DROP COLUMN "canBeAssignedToAgents"`,
);
await queryRunner.query(
`ALTER TABLE "core"."role" DROP COLUMN "canBeAssignedToUsers"`,
);
}
}