Skip to content

Commit

Permalink
N21-1967 Fix migration of file records (#5062)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap authored Jun 12, 2024
1 parent d2edfc0 commit a9e9163
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions apps/server/src/migrations/mikro-orm/Migration20240612122202.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Migration } from '@mikro-orm/migrations-mongodb';

export class Migration20240612122202 extends Migration {
async up(): Promise<void> {
const filerecords = await this.driver.nativeUpdate('filerecords', {}, { $rename: { school: 'storageLocationId' } });

console.info(`${filerecords.affectedRows} Filerecords were migrated to "storageLocationId"`);
}

async down(): Promise<void> {
const filerecords = await this.driver.nativeUpdate('filerecords', {}, { $rename: { storageLocationId: 'school' } });

console.info(`${filerecords.affectedRows} Filerecords were rolled back to use "schoolId"`);
}
}
9 changes: 9 additions & 0 deletions backup/setup/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,14 @@
"created_at": {
"$date": "2024-06-11T13:08:13.069Z"
}
},
{
"_id": {
"$oid": "666993d9c1989bee3e0e5df2"
},
"name": "Migration20240612122202",
"created_at": {
"$date": "2024-06-12T12:26:01.665Z"
}
}
]

0 comments on commit a9e9163

Please sign in to comment.