Skip to content

Commit 6329889

Browse files
committed
(when you find yourself in a hole; keep digging)
1 parent 300a1e7 commit 6329889

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

server/src/lib/migration/migrations/chunithm-lamp-split.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,22 @@ const migration: Migration = {
213213
};
214214
},
215215
async (changes) => {
216+
const changesPrime = [];
217+
218+
for (const change of changes) {
219+
const scoreExists = await db.scores.findOne({
220+
scoreID: change.newScore.scoreID,
221+
});
222+
223+
if (scoreExists) {
224+
continue;
225+
}
226+
227+
changesPrime.push(change);
228+
}
229+
216230
await db.scores.bulkWrite(
217-
changes.map((c) => ({
231+
changesPrime.map((c) => ({
218232
updateOne: {
219233
filter: {
220234
scoreID: c.oldScoreID,

0 commit comments

Comments
 (0)