-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(server): 🐛 remove administrationName from added sections if null
- Loading branch information
1 parent
6fe9d4f
commit 4e9babe
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { MigrationInterface } from "mongo-migrate-ts"; | ||
import { Db } from "mongodb"; | ||
|
||
export class Migration1733826190794 implements MigrationInterface { | ||
public async up(db: Db): Promise<void | never> { | ||
const trads = await db.collection("traductions").find({ toReview: "content.administrationName" }).toArray(); | ||
for (const trad of trads) { | ||
const dispositif = await db.collection("dispositifs").findOne({ _id: trad.dispositifId }); | ||
if (dispositif && dispositif.translations.fr.content.administrationName === null) { | ||
//@ts-ignore | ||
await db | ||
.collection("traductions") | ||
.updateOne( | ||
{ _id: trad._id }, | ||
{ $pull: { toReview: "content.administrationName", toReviewCache: "content.administrationName" } }, | ||
); | ||
} | ||
} | ||
} | ||
|
||
public async down(db: Db): Promise<void | never> {} | ||
} |