diff --git a/api/migrations/20250130154020-expendExpirationTokenDate.js b/api/migrations/20250130154020-expendExpirationTokenDate.js new file mode 100644 index 0000000000..19857e3705 --- /dev/null +++ b/api/migrations/20250130154020-expendExpirationTokenDate.js @@ -0,0 +1,17 @@ +const { ReferentModel } = require("../src/models"); + +module.exports = { + async up() { + const inOneMonth = new Date(); + inOneMonth.setMonth(inOneMonth.getMonth() + 1); + + await ReferentModel.updateMany( + { + role: "referent_classe", + invitationToken: { $exists: true, $nin: ["", null] }, + "metadata.invitationType": { $exists: true }, + }, + { $set: { invitationExpires: inOneMonth } }, + ); + }, +};