diff --git a/imports/plugins/core/versions/server/migrations/17_set_shop_uols.js b/imports/plugins/core/versions/server/migrations/17_set_shop_uols.js new file mode 100644 index 00000000000..0f2ca03c75a --- /dev/null +++ b/imports/plugins/core/versions/server/migrations/17_set_shop_uols.js @@ -0,0 +1,39 @@ +import { Migrations } from "meteor/percolate:migrations"; +import { Shops } from "/lib/collections"; + +Migrations.add({ + // Initializes shops without a baseUOL and without unitsOfLength to our default + version: 17, + up() { + Shops.update({ + baseUOL: { $exists: false }, + unitsOfLength: { $exists: false } + }, { + $set: { + baseUOL: "in", + unitsOfLength: [{ + uol: "in", + label: "Inches", + default: true + }, { + uol: "cm", + label: "Centimeters" + }, { + uol: "ft", + label: "Feet" + }] + } + }, { multi: true }); + }, + down() { + Shops.update({ + baseUOL: { $exists: true }, + unitsOfLength: { $exists: true } + }, { + $unset: { + baseUOL: "", + unitsOfLength: "" + } + }, { multi: true }); + } +}); diff --git a/imports/plugins/core/versions/server/migrations/index.js b/imports/plugins/core/versions/server/migrations/index.js index 9bbd0c804d2..5298528e16a 100644 --- a/imports/plugins/core/versions/server/migrations/index.js +++ b/imports/plugins/core/versions/server/migrations/index.js @@ -14,3 +14,4 @@ import "./13_add_shopId_on_shipping"; import "./14_rebuild_order_search_collection"; import "./15_update_shipping_status_to_workflow"; import "./16_update_billing_paymentMethod"; +import "./17_set_shop_uols";