Skip to content

Commit

Permalink
fix(server): fix printer name issue with database migration from old …
Browse files Browse the repository at this point in the history
…value, closes #1176 #1179 #1180 #1178
  • Loading branch information
NotExpectedYet committed Aug 7, 2022
1 parent 04cb94e commit 90e8456
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions server/migrations/20220807120034-printer-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
async up(db, client) {
const session = client.startSession();
try {
// Safety first
await session.withTransaction(async () => {
// Do the migration
const dbCollection = db.collection("printers");

await dbCollection.find({}).forEach(function (data) {
dbCollection.findOneAndUpdate(
{ _id: data._id },
{
$set: {
printerName: data.settingsAppearance.name
}
}
);
});
});
} finally {
await session.endSession();
}
}
};

0 comments on commit 90e8456

Please sign in to comment.