2.8 KiB
v1.3.1
Version 1.3.1 of Medusa introduces new features including the addition of Line Item Adjustments and a more advanced Promotions API. The changes do not affect the public APIs and require only running necessary data migrations.
Prerequisites
Both the actions required for this update need you to set the following environment variables:
TYPEORM_CONNECTION=postgres
TYPEORM_URL=<DATABASE_URL>
TYPEORM_LOGGING=true
TYPEORM_ENTITIES=./node_modules/@medusajs/medusa/dist/models/*.js
TYPEORM_MIGRATIONS=./node_modules/@medusajs/medusa/dist/migrations/*.js
These environment variables are used in the data migration scripts in this upgrade. Make sure to replace <DATABASE_URL> with your PostgreSQL database URL.
Line Item Adjustments
This new version of Medusa allows store operators to adjust line items in an order or a swap which provides more customization capabilities.
It introduces a new model LineItemAdjustment which gives more flexibility to adjust the pricing of line items in a cart, order, or swap. A discount can be added, removed, or modified and the price will reflect on the total calculation of the cart, order, or swap.
This also introduces an optimization to the calculation of totals, as it is no longer necessary to calculate the discounts every time the totals are retrieved.
Actions Required
This new version adds a new data migration script that will go through your list of existing orders and add line item adjustments for each of the line items in the order.
For that reason, it’s essential to run the data migration script after upgrading your server and before starting your Medusa server:
node ./node_modules/@medusajs/medusa/dist/scripts/line-item-adjustment-migration.js
Advanced Discount Conditions
This new version of Medusa holds advanced promotions functionalities to provide store operators with even more customization capabilities when creating discounts. You can now add even more conditions to your discounts to make them specific for a set of products, collections, customer groups, and more.
This change required creating a new model DiscountCondition which belongs to DiscountRule and includes a few relationships with other models to make the aforementioned feature possible.
Actions Required
To ensure your old discount rules play well with the new Promotions API and schema, this version includes a migration script that will go through your existing discount rules, create discount conditions for these rules, and move the former direct relationship between discount rules and products to become between discount conditions and products.
For that reason, it’s essential to run the data migration script after upgrading your server and before starting your Medusa server:
node ./node_modules/@medusajs/medusa/dist/scripts/discount-rule-migration.js