Skip to content

Commit

Permalink
fix(Visualisations): Correct LAST_1_YEARS typo in DB (#1401)
Browse files Browse the repository at this point in the history
  • Loading branch information
h-kanazawa authored and asahd committed Jul 22, 2019
1 parent 406a5dd commit 3e5a83e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
23 changes: 23 additions & 0 deletions cli/src/commands/fixTypoLast1Years.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logger from 'lib/logger';
import Visualisation from 'lib/models/visualisation';

const OLD_VALUE = 'LAST_1_YEARS';
const NEW_VALUE = 'LAST_2_YEARS';

export const back = async () => {
try {
await Visualisation.updateMany({ previewPeriod: NEW_VALUE }, { $set: { previewPeriod: OLD_VALUE } });
} catch (error) {
logger.error(error);
}
};

export const fix = async () => {
try {
await Visualisation.updateMany({ previewPeriod: OLD_VALUE }, { $set: { previewPeriod: NEW_VALUE } });
} catch (error) {
logger.error(error);
}
};

export default fix;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { fix, back } from '../fixTypoLast1Years';

const up = async () => {
await fix();
};

const down = async () => {
await back();
};

export default { up, down };
4 changes: 3 additions & 1 deletion cli/src/commands/v2-migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import personaAttributesIndexes from './20190212150000_personaAttributes_indexes
import oauthTokens from './20190131000000_oauth_tokens';
import migrateToInQueries from './20190307130000_migrate_to_in_queries';
import migrateResetTokens from './20190509000000_migrate_null_resetTokens';
import fixTypoLast1Years from './20190627000000_fix_typo_last_1_years';
import personaImports from './20190711090000_persona_imports';

export default new OrderedMap()
Expand All @@ -24,4 +25,5 @@ export default new OrderedMap()
.set('20190212150000_personaAttributes_indexes', personaAttributesIndexes)
.set('20190307130000_migrate_to_in_queries', migrateToInQueries)
.set('20190509000000_migrate_null_resetTokens', migrateResetTokens)
.set('20190711090000_persona_imports', personaImports);
.set('20190711090000_persona_imports', personaImports)
.set('20190627000000_fix_typo_last_1_years', fixTypoLast1Years);

0 comments on commit 3e5a83e

Please sign in to comment.