Skip to content

Conversation

@aldeed
Copy link
Contributor

@aldeed aldeed commented May 24, 2018

Resolves #4197
Impact: minor
Type: feature

Changes

PR #4218 changed the catalog schema but did not migrate existing data. This is the migration.

Breaking changes

The breaking changes were outlined in PR #4218. This PR does not break anything further.

Testing

  1. Check out master branch and reset the database.
  2. As admin, create at least one product with images, variants, and options, and as many properties filled out as possible.
  3. Without resetting the database, check out this branch and start the app.
  4. As a shop customer (not admin), verify that everything looks correct in the product grid and there are no errors in the console.

@aldeed aldeed self-assigned this May 24, 2018
@aldeed aldeed added this to the Elbert milestone May 24, 2018
@aldeed aldeed requested a review from spencern May 24, 2018 15:57
@spencern spencern modified the milestones: Elbert, Fletcher May 29, 2018
@aldeed aldeed changed the title [WIP] Catalog schema migration Catalog schema migration May 29, 2018
@aldeed
Copy link
Contributor Author

aldeed commented May 29, 2018

This is ready for review. @spencern do you want to review this or should I assign to someone else?

@spencern
Copy link
Contributor

@aldeed I'll check this one out.

Copy link
Contributor

@spencern spencern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aldeed I ran this migration against a db that was loaded with 1k products with images via dev-tools from master to this branch. No products were added to the catalog during the migration.

Realized that's actually not what this PR is doing.

Reset everything, loaded up a master branch, loaded 1k products, hit "publish all" which only publishes the products loaded on the grid at the time, not everything in a particular query. Added a few images and published.

Loaded up your branch, the migration ran successfully, but the products that were published had their order reversed.

My guess is that it's due to the updatedAt date being set by your do while.. loop and it's essentially flipping which products were updated most recently.

Not sure if this is a blocker, as updatedAt is not a very consistent merchandising sort anyway.

Otherwise, things looked good.

let items;

do {
items = Catalog.find({ product: { $exists: false } }, { limit: LIMIT }).fetch();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding a sort: { updatedAt: 1 } to the options here would keep everything in the same order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was on the fence about whether a migration should change updatedAt anyway. Thoughts? It is technically updating the doc, but it might also be misleading for all of the updatedAt to update since they were more "rearranged" than "updated"

@aldeed
Copy link
Contributor Author

aldeed commented May 30, 2018

@spencern Grid is sorted by manual positions, then createdAt. So I added sort by createdAt rather than updatedAt. But I think the cause of what you saw was because I forgot to transform the positions object to the new format.

My changes are pushed but I didn't retest manually yet. If you retest before I do and it looks fixed, I'm cool with merging this.

@spencern spencern merged commit fc09557 into release-1.12.0 May 30, 2018
@spencern spencern deleted the feat-4197-aldeed-catalog-schema-migration branch May 30, 2018 23:24
@spencern spencern mentioned this pull request May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants