-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b57178e
commit c70a004
Showing
4 changed files
with
36 additions
and
10 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -6,6 +6,9 @@ on: | |
pull_request: | ||
branches: [ main ] | ||
|
||
env: | ||
MONGODB_VERSION: 4.4 | ||
NODE_VERSION: '18' | ||
jobs: | ||
migration: | ||
runs-on: ubuntu-latest | ||
|
@@ -14,19 +17,13 @@ jobs: | |
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: check all migrations are up in database seed | ||
run: test $(grep "\"down\"" ./backup/setup/migrations.json -c) -eq 0 | ||
- name: mongodb setup | ||
uses: supercharge/[email protected] | ||
- name: setup | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '16' | ||
node-version: ${{ env.NODE_VERSION }} | ||
- run: npm ci | ||
- run: npm run setup:db:seed | ||
- name: check migrations.json formatting | ||
run: | | ||
npm run migration:persisted | ||
git diff --exit-code backup/** | ||
- name: check filesystem migrations have been added to database | ||
run: npm run migration:list | ||
- name: check no pending migrations (migration is in db) | ||
run: npx mikro-orm migration:pending |
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
29 changes: 29 additions & 0 deletions
29
apps/server/src/migrations/mikro-orm/Migration20240115103302.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,29 @@ | ||
import { Migration } from '@mikro-orm/migrations-mongodb'; | ||
|
||
// remove-undefined-parameters-from-external-tool | ||
export class Migration20240115103302 extends Migration { | ||
async up(): Promise<void> { | ||
const contextExternalToolResponse = await this.driver.nativeUpdate( | ||
'context-external-tools', | ||
{ $or: [{ 'parameters.value': undefined }, { 'parameters.value': '' }] }, | ||
{ $pull: { parameters: { $or: [{ value: undefined }, { value: '' }] } } } | ||
// { ctx: this.ctx } | ||
); | ||
|
||
console.info(`Removed ${contextExternalToolResponse.affectedRows} parameter(s) in context-external-tools`); | ||
|
||
const schoolExternalToolResponse = await this.driver.nativeUpdate( | ||
'school-external-tools', | ||
{ $or: [{ 'parameters.value': undefined }, { 'parameters.value': '' }] }, | ||
{ $pull: { parameters: { $or: [{ value: undefined }, { value: '' }] } } } | ||
// { ctx: this.ctx } | ||
); | ||
|
||
console.info(`Removed ${schoolExternalToolResponse.affectedRows} parameter(s) in school-external-tools`); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/require-await | ||
async down() { | ||
console.error('This migration cannot be undone'); | ||
} | ||
} |
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