diff --git a/src/migrations/scripts/1695223467052-remove-pix-label.ts b/src/migrations/scripts/1695223467052-remove-pix-label.ts new file mode 100644 index 0000000000000000000000000000000000000000..4bbeeb0189aec877c1cad85163e564163f0d7481 --- /dev/null +++ b/src/migrations/scripts/1695223467052-remove-pix-label.ts @@ -0,0 +1,30 @@ +import { Db } from 'mongodb'; +import { getDb } from '../migrations-utils/db'; + +export const up = async () => { + const db: Db = await getDb(); + + await db.collection('categories').updateOne( + { id: 'labelsQualifications' }, + { + $pull: { modules: { id: 'pix' } }, + } + ); + + await db.collection('structures').updateMany({ 'categories.labelsQualifications': 'pix' }, { + $pull: { 'categories.labelsQualifications': 'pix' }, + } as unknown); + + console.log('Updated : Pix label removed'); +}; + +export const down = async () => { + const db: Db = await getDb(); + await db.collection('categories').updateOne( + { id: 'labelsQualifications' }, + { + $push: { modules: { id: 'pix', name: 'Pix' } }, + } + ); + console.log('Downgraded : Pix label added'); +};