Skip to content

Commit

Permalink
[HOTFIX] Migration 148 is now "idempotent" (#6236)
Browse files Browse the repository at this point in the history
* migration 148 is now "idempotent"

* bump version
  • Loading branch information
daneryl authored Nov 6, 2023
1 parent 58c15d6 commit 50141a3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ export default {
async up(db) {
const settings = await db.collection('settings').findOne();
const languages = settings.languages.map(l => l.key);
await db
.collection('translationsV2')
.deleteMany({ key: { $in: deletedKeys.map(k => k.key) }, 'context.id': 'System' });

await db.collection('translationsV2').deleteMany({
key: { $in: deletedKeys.concat(newKeys).map(k => k.key) },
'context.id': 'System',
});

const insertMany = languages.map(l =>
db.collection('translationsV2').insertMany(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ describe('migration update translations of settings new Users/Groups UI', () =>

expect(translations.length).toBe(newKeys.length * fixtures.settings[0].languages.length);
});

it('should be idempotent (do not throw an error on multiple runs)', async () => {
await expect(migration.up(testingDB.mongodb)).resolves.toBe(undefined);
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uwazi",
"version": "1.141.0",
"version": "1.141.1",
"description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.",
"keywords": [
"react"
Expand Down

0 comments on commit 50141a3

Please sign in to comment.