Skip to content

Commit

Permalink
Merge branch 'main' into N21-1631-change-ctl-error-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MBergCap committed Apr 22, 2024
2 parents 507ad34 + 0eb574b commit 9e0d4e6
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
50 changes: 50 additions & 0 deletions apps/server/src/migrations/mikro-orm/Migration20240416104203.ts
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.'
);
}
}
}
}
9 changes: 9 additions & 0 deletions backup/setup/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,14 @@
"created_at": {
"$date": "2024-04-19T08:32:50.668Z"
}
},
{
"_id": {
"$oid": "66263de3e9af8b2c09707e51"
},
"name": "Migration20240416104203",
"created_at": {
"$date": "2024-04-22T12:32:50.668Z"
}
}
]
2 changes: 1 addition & 1 deletion backup/setup/roles.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
},
"name": "teacher",
"updatedAt": {
"$date": "2023-10-18T05:59:16.621Z"
"$date": "2024-04-19T10:32:51.070Z"
},
"createdAt": {
"$date": "2017-01-01T00:06:37.148Z"
Expand Down

0 comments on commit 9e0d4e6

Please sign in to comment.