Repository navigation
fix(server): backport role backfill migrations to the apps/server tree #2814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
apps/server/src/prisma/migrations/20260907170000_backfill_project_roles/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| -- Backfill the 4 default system roles on projects that have none. | ||
| -- Mirrors generateProjectCreateInput (apps/server-nestjs/src/modules/project/project.utils.ts): | ||
| -- Administrateur = MANAGE = 2 | ||
| -- DevOps = MANAGE_ENVIRONMENTS | MANAGE_REPOSITORIES | REPLAY_HOOKS | ||
| -- | SEE_SECRETS | LIST_ENVIRONMENTS | LIST_REPOSITORIES = 984 | ||
| -- Développeur = MANAGE_REPOSITORIES | LIST_ENVIRONMENTS | LIST_REPOSITORIES = 784 | ||
| -- Lecture seule = LIST_ENVIRONMENTS | LIST_REPOSITORIES = 768 | ||
| INSERT INTO "ProjectRole" ("id", "name", "permissions", "position", "oidcGroup", "type", "projectId") | ||
| SELECT | ||
| gen_random_uuid(), | ||
| r."name", | ||
| r."permissions", | ||
| r."position", | ||
| '/' || p."slug" || r."groupSuffix", | ||
| 'system:managed', | ||
| p."id" | ||
| FROM "Project" p | ||
| CROSS JOIN (VALUES | ||
| ('Administrateur', 2::bigint, 0, '/console/admin'), | ||
| ('DevOps', 984::bigint, 1, '/console/devops'), | ||
| ('Développeur', 784::bigint, 2, '/console/developer'), | ||
| ('Lecture seule', 768::bigint, 3, '/console/readonly') | ||
| ) AS r("name", "permissions", "position", "groupSuffix") | ||
| WHERE NOT EXISTS ( | ||
| SELECT 1 FROM "ProjectRole" existing WHERE existing."projectId" = p."id" | ||
| ); | ||
24 changes: 24 additions & 0 deletions
24
apps/server/src/prisma/migrations/20260908155700_add_security_role/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| -- Backfill the project system role 'Sécurité' on existing projects. | ||
| -- Mirrors the TS seeding in project.utils.ts (generateProjectCreateInput): | ||
| -- permissions 832 = SEE_SECRETS(64) | LIST_ENVIRONMENTS(256) | LIST_REPOSITORIES(512) | ||
| -- position 4 (after Lecture seule), oidcGroup = '/<project.slug>/console/security' | ||
| -- Anti-join on slug+position makes the INSERT idempotent: a retry after a | ||
| -- partial failure, or a project that already has the role, is a no-op. | ||
|
|
||
| INSERT INTO "ProjectRole" ("id", "name", "permissions", "projectId", "position", "oidcGroup", "type") | ||
| SELECT | ||
| gen_random_uuid(), | ||
| 'Sécurité', | ||
| 832, -- SEE_SECRETS(64) | LIST_ENVIRONMENTS(256) | LIST_REPOSITORIES(512) | ||
| p."id", | ||
| 4, | ||
| '/' || p."slug" || '/console/security', | ||
| 'system:managed' | ||
| FROM "Project" p | ||
| WHERE NOT EXISTS ( | ||
| SELECT 1 | ||
| FROM "ProjectRole" r | ||
| WHERE r."projectId" = p."id" | ||
| AND r."position" = 4 | ||
| AND r."oidcGroup" = '/' || p."slug" || '/console/security' | ||
| ); |
13 changes: 13 additions & 0 deletions
13
apps/server/src/prisma/migrations/20260929130657_add_security_admin_role/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| INSERT INTO "AdminRole" ("id", "name", "permissions", "position", "oidcGroup", "type") | ||
| SELECT | ||
| '487450e6-3265-4df2-8581-8e39b0cecc5d'::uuid, | ||
| 'Sécurité Plateforme', | ||
| 1, | ||
| 3, | ||
| '/console/security', | ||
| 'system:managed' | ||
| WHERE NOT EXISTS ( | ||
| SELECT 1 FROM "AdminRole" | ||
| WHERE "oidcGroup" = '/console/security' | ||
| OR "id" = '487450e6-3265-4df2-8581-8e39b0cecc5d'::uuid | ||
| ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.