diff --git a/docs/content/upgrade-guides/medusa-core/1-12-0.md b/docs/content/upgrade-guides/medusa-core/1-12-0.md new file mode 100644 index 0000000000..59e0d0fdb0 --- /dev/null +++ b/docs/content/upgrade-guides/medusa-core/1-12-0.md @@ -0,0 +1,100 @@ +--- +description: 'Actions Required for v.1.12.0' +sidebar_custom_props: + iconName: 'server-stack-solid' +--- + +# 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: + +```ts +// Before +class MyStrategy extends + AbstractPriceSelectionStrategy { + // ... + calculateVariantPrice( + variantId: string, + context: PriceSelectionContext + ): Promise { + // ... + } +} +``` + +```ts +// Now +class MyStrategy extends + AbstractPriceSelectionStrategy { + // ... + calculateVariantPrice(data: { + variantId: string; + quantity?: number; + }[], + context: PriceSelectionContext + ): Promise> { + // ... + } +} +``` + +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: + +```bash npm2yarn +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: + +```bash +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: + +```ts +class MyStrategy extends + AbstractPriceSelectionStrategy { + // ... + calculateVariantPrice(data: { + variantId: string; + quantity?: number; + }[], + context: PriceSelectionContext + ): Promise> { + // ... + } +} +``` + +You can learn more in the [Price Selection Strategy](../../modules/price-lists/price-selection-strategy.md#calculatevariantprice-method) documentation.