-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HOTFIX] Migration to remove translations v1 traces (#6200)
* migration to remove translations v1 traces * bump version * fix check-translations * fix eslint
- Loading branch information
Showing
5 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
app/api/migrations/migrations/146-remove_translationsv2_traces/index.js
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,15 @@ | ||
export default { | ||
delta: 146, | ||
|
||
name: 'remove_translationsv2_traces', | ||
|
||
description: 'remove translations collection and translations updatelogs', | ||
|
||
reindex: false, | ||
|
||
async up(db) { | ||
process.stdout.write(`${this.name}...\r\n`); | ||
await db.collection('translations').drop(); | ||
await db.collection('updatelogs').deleteMany({ namespace: 'translations' }); | ||
}, | ||
}; |
34 changes: 34 additions & 0 deletions
34
...igrations/146-remove_translationsv2_traces/specs/146-remove_translationsv2_traces.spec.js
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,34 @@ | ||
import testingDB from 'api/utils/testing_db'; | ||
import migration from '../index.js'; | ||
import { fixtures } from './fixtures.js'; | ||
|
||
describe('migration remove_translationsv2_traces', () => { | ||
beforeEach(async () => { | ||
jest.spyOn(process.stdout, 'write').mockImplementation(() => {}); | ||
await testingDB.setupFixturesAndContext(fixtures); | ||
}); | ||
|
||
afterAll(async () => { | ||
await testingDB.tearDown(); | ||
}); | ||
|
||
it('should have a delta number', () => { | ||
expect(migration.delta).toBe(146); | ||
}); | ||
|
||
it('should check if a reindex is needed', async () => { | ||
expect(migration.reindex).toBe(false); | ||
}); | ||
|
||
it('should delete translations collection', async () => { | ||
await migration.up(testingDB.mongodb); | ||
const collectionNames = (await testingDB.mongodb.listCollections().toArray()).map(c => c.name); | ||
expect(collectionNames.includes('translations')).toBe(false); | ||
}); | ||
|
||
it('should delete all translations entries in updatelogs', async () => { | ||
await migration.up(testingDB.mongodb); | ||
const updatelogs = await testingDB.mongodb.collection('updatelogs').find().toArray(); | ||
expect(updatelogs).toMatchObject([{ namespace: 'migrations' }, { namespace: 'entities' }]); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
app/api/migrations/migrations/146-remove_translationsv2_traces/specs/fixtures.js
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,9 @@ | ||
export const fixtures = { | ||
translations: [{}], | ||
updatelogs: [ | ||
{ namespace: 'migrations' }, | ||
{ namespace: 'translations' }, | ||
{ namespace: 'entities' }, | ||
{ namespace: 'translations' }, | ||
], | ||
}; |
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
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