Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) Add migration for index #5358

Merged
merged 4 commits into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Migrations } from "meteor/percolate:migrations";
import Logger from "@reactioncommerce/logger";
import rawCollections from "/imports/collections/rawCollections";

/**
* @private
* @param {Error} error Error or null
* @return {undefined}
*/
function handleError(error) {
// This may fail if the index or the collection doesn't exist, which is what we want anyway
if (
error &&
(
typeof error.message !== "string" ||
(!error.message.includes("index not found") && !error.message.includes("ns not found"))
)
) {
Logger.warn(error, "Caught error from dropIndex calls in migration 69");
}
}

/**
* Drop all indexes that support queries that are no longer expected
* to be made by any plugins, or that are already supported by other
* indexes.
*/
Migrations.add({
version: 69,
up() {
const { Catalog } = rawCollections;
Catalog.dropIndex("productId", handleError);
Catalog.createIndex("productId", handleError);
brent-hoover marked this conversation as resolved.
Show resolved Hide resolved
Catalog.dropIndex("product._id", handleError);
Catalog.createIndex("product._id", handleError);
}
});
1 change: 1 addition & 0 deletions imports/plugins/core/versions/server/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ import "./65_update_navigation_tree";
import "./66_attribute_labels";
import "./67_order_tokens";
import "./68_add_is_sold_out_to_variants_and_options";
import "./69_make_catalog_product_unique";