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

New data migration fulfillment #6633

Merged
merged 10 commits into from
May 18, 2023

Conversation

sujithvn
Copy link
Contributor

@sujithvn sujithvn commented Nov 7, 2022

Resolves #6472
Impact: breaking
Type: feature

This is replacement PR for #6544

Issue

Migrate data to the new format required for the new FFT plugins

Solution

We have 3 stages in a single migration;

  • Copies over the existing Shipments & FlatRateFulfillmentRestrictions collections to Fulfillment & FulfillmentRestrictions collections respectively
  • Updates the Fulfillment collection with the newly introduced fields (fulfillmentType & fulfillmentMethod). Since the existing user base had only Shipping/Flatrate as the fulfillment type/method till date, we would be using those values to update collection
  • update the Groups collection with the new permissions

Breaking changes

The 2nd stage above handles the breaking change where we would be using the possible existing values as the values or newly introduced fields.

Testing

In an existing installation, perform the data-migration. Update the installation to use the new version having fulfillment types. All activities in admin/shop (related to Products/Orders/FF-types/Catalogs/Carts) should continue to work without issues

To test migration steps, install api-migrations package and include the below entry in the migrator.config.js file.

export default {
  tracks: [
    {
      namespace: "fulfillment",
      package: "../reaction/packages/api-plugin-fulfillment",
      version: 2
    }
  ]
};

Run the command:
MONGO_URL=mongodb://localhost:27017/reaction npx migrator migrate

Signed-off-by: Sujith <mail.sujithvn@gmail.com>
Signed-off-by: Sujith <mail.sujithvn@gmail.com>
Signed-off-by: Sujith <mail.sujithvn@gmail.com>
Signed-off-by: Sujith <mail.sujithvn@gmail.com>
Signed-off-by: Sujith <mail.sujithvn@gmail.com>
Signed-off-by: Sujith <mail.sujithvn@gmail.com>
@changeset-bot
Copy link

changeset-bot bot commented Nov 7, 2022

⚠️ No Changeset found

Latest commit: 13bab48

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Signed-off-by: Sujith <mail.sujithvn@gmail.com>
Copy link
Collaborator

@zenweasel zenweasel left a comment

Choose a reason for hiding this comment

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

Just suggesting using regular operations rather than bulk operations

operations.push(ffTypeUpdate);
operations.push(ffMethodUpdate);

const bulkWriteResp = await db.collection(COLL_DEST).bulkWrite(operations);
Copy link
Collaborator

@zenweasel zenweasel Dec 9, 2022

Choose a reason for hiding this comment

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

This will probably work but it's not really what the bulkWrite API is really for an would probably be better as written as a single query. Bulkwrite is when you are doing a large amount of atomic operations, not one large one.

});
}
if (permsToAdd.length) {
permsToAdd.push("reaction:legacy:fulfillmentTypes/update:settings"); // add this setting to groups deailing with ff-types
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo in comment: dealing

…ction into 00-fulfillment-base

Signed-off-by: Sujith <mail.sujithvn@gmail.com>
Conflict res: pnpm-lock, preStartup

Signed-off-by: Sujith <mail.sujithvn@gmail.com>
Signed-off-by: Sujith <mail.sujithvn@gmail.com>
@sujithvn sujithvn merged commit 1ec99f9 into 00-fulfillment-base May 18, 2023
2 checks passed
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.

None yet

4 participants