-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into N21-1631-change-ctl-error-handling
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
apps/server/src/migrations/mikro-orm/Migration20240416104203.ts
This file contains 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,50 @@ | ||
import { Migration } from '@mikro-orm/migrations-mongodb'; | ||
|
||
// add migration wizard permissions to admin role | ||
export class Migration20240416104203 extends Migration { | ||
async up(): Promise<void> { | ||
// eslint-disable-next-line no-process-env | ||
if (process.env.SC_THEME !== 'thr') { | ||
const adminRoleUpdate = await this.driver.nativeUpdate( | ||
'roles', | ||
{ name: 'administrator' }, | ||
{ | ||
$addToSet: { | ||
permissions: { | ||
$each: ['IMPORT_USER_MIGRATE', 'IMPORT_USER_UPDATE', 'IMPORT_USER_VIEW'], | ||
}, | ||
}, | ||
} | ||
); | ||
|
||
if (adminRoleUpdate.affectedRows > 0) { | ||
console.info( | ||
'Permissions IMPORT_USER_MIGRATE, IMPORT_USER_UPDATE, IMPORT_USER_VIEW were added to role administrator.' | ||
); | ||
} | ||
} | ||
} | ||
|
||
async down(): Promise<void> { | ||
// eslint-disable-next-line no-process-env | ||
if (process.env.SC_THEME !== 'thr') { | ||
const adminRoleUpdate = await this.driver.nativeUpdate( | ||
'roles', | ||
{ name: 'administrator' }, | ||
{ | ||
$pull: { | ||
permissions: { | ||
$in: ['IMPORT_USER_MIGRATE', 'IMPORT_USER_UPDATE', 'IMPORT_USER_VIEW'], | ||
}, | ||
}, | ||
} | ||
); | ||
|
||
if (adminRoleUpdate.affectedRows > 0) { | ||
console.info( | ||
'Rollback: Removed permissions IMPORT_USER_MIGRATE, IMPORT_USER_UPDATE, IMPORT_USER_VIEW from role administrator.' | ||
); | ||
} | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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