docs: Add 1.12.0 upgrade guide (#4204)
* docs: Add 1.12.0 upgrade guide * Add note on breaking changes * added new action required * eslint fixes * Add another breaking change note --------- Co-authored-by: Shahed Nasser <shahednasser@gmail.com>
This commit is contained in:
1 parent
b7f236445a
commit
f3920730dc
1 file changed
+100
@@ -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<PriceSelectionResult> {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// 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:
|
||||||
|
|
||||||
|
```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<Map<string, PriceSelectionResult>> {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can learn more in the [Price Selection Strategy](../../modules/price-lists/price-selection-strategy.md#calculatevariantprice-method) documentation.
|
||||||
Reference in new issue
Block a user