diff --git a/src/migrations/scripts/1652274718695-rename-caf.ts b/src/migrations/scripts/1652274718695-rename-caf.ts new file mode 100644 index 0000000000000000000000000000000000000000..52597a36112a8b14f81f7e43167bb1d698476a71 --- /dev/null +++ b/src/migrations/scripts/1652274718695-rename-caf.ts @@ -0,0 +1,32 @@ +import { Db } from 'mongodb'; +import { getDb } from '../migrations-utils/db'; + +export const up = async () => { + const db: Db = await getDb(); + + await db + .collection('categoriesaccompagnements') + .updateOne( + { id: 'proceduresAccompaniment', 'modules.id': 'accompagnantCaf' }, + { $set: { 'modules.$.text': 'CAF' } } + ); + + console.log( + 'Updated done: "Accompagnement CAF" to "CAF" from collection "categoriesAccompanements" with document id "proceduresAccompaniment"' + ); +}; + +export const down = async () => { + const db: Db = await getDb(); + + await db + .collection('categoriesaccompagnements') + .updateOne( + { id: 'proceduresAccompaniment', 'modules.id': 'accompagnantCaf' }, + { $set: { 'modules.$.text': 'Accompagnement CAF' } } + ); + + console.log( + 'Downgraded "CAF" to "Accompagnement CAF" from collection "categoriesAccompanements" with document id "proceduresAccompaniment"' + ); +};