Skip to content
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

N21-2106 Fix oauth school feature #5145

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!`);
}
}
9 changes: 9 additions & 0 deletions backup/setup/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,14 @@
"created_at": {
"$date": "2024-07-24T09:11:11.359Z"
}
},
{
"_id": {
"$oid": "66a267da6d71e4510a572d08"
},
"name": "Migration20240725143018",
"created_at": {
"$date": "2024-07-25T14:57:30.752Z"
}
}
]
Loading