npm @medusajs/medusa 2.0.7
v2.0.7

latest releases: 2.0.2-preview-20241128090232, 2.0.8-preview-20241128090154, 2.0.2-preview-20241128060235...
21 hours ago

Highlights

Order transfers

You can now transfer order ownership between customers. We've added UI support in three places:

  • Order details page in Medusa Admin
  • Customer details page (Order list) in Medusa Admin
  • Self-serve in our Next.js and B2B starters

The high-level flow is as follows:

  1. Initiate transfer
POST /admin/orders/:id/transfer  { customer_id: string }

Send a request to generate a transfer token and emit an event with the order ID.

  1. Event subscriber

A subscriber picks up the event and emails the order’s current customer with the token.

  1. Accept Transfer

Customer accepts the order transfer.

POST /store/orders/:id/transfer/accept { token: string }

Product Module DML migration

Warning

Breaking changes (avoidable)

The Product module now uses our DML for data model definitions instead of MikroORM. This migration introduces improvements and fixes but results in breaking changes to some relationship APIs. These can be avoided through explicit configurations.

Required actions

  • Relation ownership on manyToMany relation

Previously, the manyToMany API inferred the owning side of relations based on the order of loading models. If the first-loaded model used mappedBy, it became the owner. Now, ownership is determined by examining both sides of the relation, before defaulting to the old behavior. This change might lead to unexpected behavior, and we therefore recommend explicitly defining the owner.

Explicitly define the owner using joinColumn, inverseJoinColumn, or pivotTable:

const ProductVariant = model
  .define("ProductVariant", {
    id: model.id({ prefix: "variant" }).primaryKey(),
    ...
    options: model.manyToMany(() => ProductOptionValue, {
      pivotTable: "product_variant_option",
      mappedBy: "variants",
      joinColumn: "variant_id",
      inverseJoinColumn: "option_value_id",
    }),
  })
  • Pivot table naming

Aside from the relation ownership, we have also updated how pivot table names are generated.

Before

We used the model names in alphabetical order and pluralized the last one of them.

Now

We use the model's table names in alphabetical order and pluralize the last one of them.

To avoid issues with your project, explicitly set pivotTable in manyToMany relations to match your existing table names:

For example:

const user = model.define('User', () => {
  addresses: model.manyToMany(() => Address, { pivotTable: 'address_users' })
})

New languages

Our admin dashboard has been translated into Brazilian Portuguese, French, Thai, and Spanish.

Features

Bugs

Documentation

Chores

New Contributors

Full Changelog: v2.0.6...v2.0.7

Don't miss a new medusa release

NewReleases is sending notifications on new releases.