From eb44f98966231be01621a1c5cf2f37ab166a2e2d Mon Sep 17 00:00:00 2001 From: Fufeck Date: Mon, 1 Jul 2024 11:32:07 +0200 Subject: [PATCH] fix: error dataGouvOrganizationId empty --- .../24-07-01_empty-dataGouvOrganizationId.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 server/migrations/24-07-01_empty-dataGouvOrganizationId.js diff --git a/server/migrations/24-07-01_empty-dataGouvOrganizationId.js b/server/migrations/24-07-01_empty-dataGouvOrganizationId.js new file mode 100644 index 0000000..0ad421e --- /dev/null +++ b/server/migrations/24-07-01_empty-dataGouvOrganizationId.js @@ -0,0 +1,27 @@ +const mongoClient = require("../utils/mongo-client"); + +const collectionName = "partenaires-de-la-charte"; + +async function main() { + await mongoClient.connect(); + + await mongoClient.db.collection(collectionName).updateMany( + { dataGouvOrganizationId: [""] }, + { + $set: { + dataGouvOrganizationId: [], + }, + } + ); + + await mongoClient.disconnect(); +} + +main() + .catch((error) => { + console.error(error); + process.exit(1); + }) + .then(() => { + process.exit(0); + });