Skip to main content

v1.12.0

Version 1.12.0 of Medusa comes with database changes that require you run the migrations command and a minor breaking change to the PriceSelectionStrategy.

Overview

This release contains migrations that introduce a range of new database indexes that will improve performance of your setup.

Additionally, it brings minor breaking changes to the PriceSelectionStrategy. The method calculateVariantPrice now supports bulk calculating variant prices.

Specifically, the following signature has changed:

// Before
class MyStrategy extends
AbstractPriceSelectionStrategy {
// ...
calculateVariantPrice(
variantId: string,
context: PriceSelectionContext
): Promise<PriceSelectionResult> {
// ...
}
}
// Now
class MyStrategy extends
AbstractPriceSelectionStrategy {
// ...
calculateVariantPrice(data: {
variantId: string;
quantity?: number;
}[],
context: PriceSelectionContext
): Promise<Map<string, PriceSelectionResult>> {
// ...
}
}

Finally, a clean up of our @medusajs/utils have also led to potential breaking changes. The clean-up resulted in the following:

  • The packages class-validator and class-transformer have been removed from @medusajs/utils.

  • The TransactionBaseService has been removed from @medusajs/utils. This class should be imported from @medusajs/medusa.

  • The utilities build-query, db-aware-column, base-entity, and soft-deletable-entity have been removed from @medusajs/medusa. These should be imported from @medusajs/medusa.


How to Update

Run the following command in the root directory of your Medusa Backend:

npm install @medusajs/medusa@1.12.0

To avoid unexpected issues with dependencies, it is also recommended to update all other Medusa plugins or packages you have installed.


Actions Required

Run Migrations

After updating your Medusa server and before running it, run the following command to run the latest migrations:

npx @medusajs/medusa-cli migrations run

Change PriceSelectionStrategy method

If you've created a custom price selection strategy, or have using the PriceSelectionStrategy's calculateVariantPrice method in your custom code, make sure to update its definition or usage based on the new signature:

class MyStrategy extends 
AbstractPriceSelectionStrategy {
// ...
calculateVariantPrice(data: {
variantId: string;
quantity?: number;
}[],
context: PriceSelectionContext
): Promise<Map<string, PriceSelectionResult>> {
// ...
}
}

You can learn more in the Price Selection Strategy documentation.

Was this page helpful?