Skip to content

Commit

Permalink
fix: ajout de migration pour supprimer les entrées referentielopcos n…
Browse files Browse the repository at this point in the history
…on valides (#876)
  • Loading branch information
remy-auricoste authored Nov 30, 2023
1 parent 477c184 commit 6d6ecc6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/src/db/migrations/20231129170900-clean-referentielopcos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ZReferentielOpco } from "shared/models"

import { logger } from "@/common/logger"
import { ReferentielOpco } from "@/common/model"

export const up = async () => {
const referentielOpcos = await ReferentielOpco.find({}).lean()
const toBeDeletedOpcos = referentielOpcos.filter((refOpco) => {
return !ZReferentielOpco.safeParse(refOpco).success
})
await ReferentielOpco.deleteMany({ _id: { $in: toBeDeletedOpcos.map((opco) => opco._id) } })

logger.info("20231129170900-clean-referentielopcos")
}

0 comments on commit 6d6ecc6

Please sign in to comment.