Skip to content

Commit

Permalink
fix oauth feature for all schools
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap committed Jul 25, 2024
1 parent 1851e7d commit 4d09caf
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions apps/server/src/migrations/mikro-orm/Migration20240725143018.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Migration } from '@mikro-orm/migrations-mongodb';

export class Migration20240725143018 extends Migration {
async up(): Promise<void> {
// eslint-disable-next-line no-process-env
if (process.env.SC_THEME !== 'n21') {
return;
}

console.info(`Adding 'oauthProvisioningEnabled' school feature to schools with moin.schule system`);

const moinSchuleSystem = await this.getCollection('systems').findOne({ alias: 'SANIS' });

if (!moinSchuleSystem) {
console.error('moin.schule system not found');
return;
}
console.info(`moin.schule system ${moinSchuleSystem._id.toHexString()} found`);

const addOauthFeatureToSchools = await this.driver.nativeUpdate(
'schools',
{ systems: moinSchuleSystem._id },
{
$addToSet: {
features: {
$each: ['oauthProvisioningEnabled'],
},
},
}
);

console.info(`Added 'oauthProvisioningEnabled' school feature to ${addOauthFeatureToSchools.affectedRows} schools`);
}

// eslint-disable-next-line @typescript-eslint/require-await
async down(): Promise<void> {
console.error(`Migration down not implemented. You might need to restore database from backup!`);
}
}

0 comments on commit 4d09caf

Please sign in to comment.