|
1
|
import { config } from "../../../config/index" |
|
2
|
|
|
3
|
export const metadata = { |
|
4
|
title: `${pageNumber} Updating Medusa`, |
|
5
|
} |
|
6
|
|
|
7
|
# {metadata.title} |
|
8
|
|
|
9
|
In this chapter, you'll learn about updating your Medusa application and packages. |
|
10
|
|
|
11
|
export const releaseNoteText = `Read the [Release Notes](${config.version.releaseUrl}).` |
|
12
|
|
|
13
|
<Note type="soon" title="Tip"> |
|
14
|
|
|
15
|
Medusa's current version is v{config.version.number}. {releaseNoteText} |
|
16
|
|
|
17
|
</Note> |
|
18
|
|
|
19
|
## Medusa Versioning |
|
20
|
|
|
21
|
When Medusa puts out a new release, all packages are updated to the same version. This ensures that all packages are compatible with each other, and makes it easier for you to switch between versions. |
|
22
|
|
|
23
|
<Note> |
|
24
|
|
|
25
|
This doesn't apply to the design-system packages, including `@medusajs/ui`, `@medusajs/ui-presets`, and `@medusajs/ui-icons`. These packages are versioned independently. However, you don't need to install and manage them separately in your Medusa application, as they are included in the `@medusajs/admin-sdk`. If you're using them in a standalone project, such as a storefront or custom admin dashboard, refer to [this section in the Medusa UI documentation](!ui!/installation/standalone-project#updating-ui-packages) for update instructions. |
|
26
|
|
|
27
|
</Note> |
|
28
|
|
|
29
|
Medusa updates the version number `major.minor.patch` according to the following rules: |
|
30
|
|
|
31
|
- **patch**: A patch release includes bug fixes and minor improvements. It doesn't include breaking changes. For example, if the current version is `2.0.0`, the next patch release will be `2.0.1`. |
|
32
|
- **minor**: A minor release includes new features, fixes, improvements, and breaking changes. For example, if the current version is `2.0.0`, the next minor release will be `2.1.0`. |
|
33
|
- **major**: A major release includes significant changes to the entire codebase and architecture. For those, the update process will be more elaborate. For example, if the current version is `2.0.0`, the next major release would be `3.0.0`. |
|
34
|
|
|
35
|
--- |
|
36
|
|
|
37
|
## Check Installed Version |
|
38
|
|
|
39
|
To check the currently installed version of Medusa in your project, run the following command in your Medusa application: |
|
40
|
|
|
41
|
```bash npx2yarn |
|
42
|
npx medusa -v |
|
43
|
``` |
|
44
|
|
|
45
|
This will show you the installed version of Medusa and the [Medusa CLI tool](!resources!/medusa-cli), which should be the same. |
|
46
|
|
|
47
|
--- |
|
48
|
|
|
49
|
## Check Latest Version |
|
50
|
|
|
51
|
The documentation shows the current version at the top right of the navigation bar. When a new version is released, you'll find a blue dot on the version number. Clicking it will take you to the [release notes on GitHub](https://github.com/medusajs/medusa/releases). |
|
52
|
|
|
53
|
You can also star the [Medusa repository on GitHub](https://github.com/medusajs/medusa) to receive updates about new releases on your GitHub dashboard. Our team also shares updates on new releases on our social media channels. |
|
54
|
|
|
55
|
--- |
|
56
|
|
|
57
|
## Update Medusa Application |
|
58
|
|
|
59
|
Before updating a Medusa application, make sure to check the [release notes](https://github.com/medusajs/medusa/releases) for any breaking changes that require actions from your side. |
|
60
|
|
|
61
|
Then, to update your Medusa application, bump the version of all `@medusajs/*` dependencies in your `package.json`. Then, re-install dependencies: |
|
62
|
|
|
63
|
```bash npm2yarn |
|
64
|
npm install |
|
65
|
``` |
|
66
|
|
|
67
|
This will update all Medusa packages to the latest version. |
|
68
|
|
|
69
|
### Running Migrations |
|
70
|
|
|
71
|
Releases may include changes to the database, such as new tables, updates to existing tables, updates after adding links, or data migration scripts. |
|
72
|
|
|
73
|
So, after updating Medusa, run the following command to migrate the latest changes to your database: |
|
74
|
|
|
75
|
```bash npx2yarn |
|
76
|
npx medusa db:migrate |
|
77
|
``` |
|
78
|
|
|
79
|
This will run all pending migrations, sync links, and run data migration scripts. |
|
80
|
|
|
81
|
### Reverting an Update |
|
82
|
|
|
83
|
Before reverting an update, if you already ran the migrations, you have to first identify the modules who had migrations. Then, before reverting, run the `db:rollback` command for each of those modules. |
|
84
|
|
|
85
|
For example, if the version you updated to had migrations for the Cart and Product Modules, run the following command: |
|
86
|
|
|
87
|
```bash npx2yarn |
|
88
|
npx medusa db:rollback cart product |
|
89
|
``` |
|
90
|
|
|
91
|
Then, revert the update by changing the version of all `@medusajs/*` dependencies in your `package.json` to the previous version and re-installing dependencies: |
|
92
|
|
|
93
|
```bash npm2yarn |
|
94
|
npm install |
|
95
|
``` |
|
96
|
|
|
97
|
Finally, run the migrations to sync link changes: |
|
98
|
|
|
99
|
```bash npx2yarn |
|
100
|
npx medusa db:migrate |
|
101
|
``` |
|
102
|
|
|
103
|
--- |
|
104
|
|
|
105
|
## Understanding Codebase Changes |
|
106
|
|
|
107
|
In the Medusa codebase, our team uses the following [TSDoc](https://tsdoc.org/) tags to indicate changes made in the latest version for a specific piece of code: |
|
108
|
|
|
109
|
- `@deprecated`: Indicates that a piece of code is deprecated and will be removed in a future version. The tag's message will include details on what to use instead. However, our updates are always backward-compatible, allowing you to update your codebase at your own pace. |
|
110
|
- `@since`: Indicates the version when a piece of code was available from. A piece of code that has this tag will only be available starting from the specified version. |
|
111
|
|
|
112
|
--- |
|
113
|
|
|
114
|
## Update Plugin Project |
|
115
|
|
|
116
|
If you have a Medusa plugin project, you only need to update its `@medusajs/*` dependencies in the `package.json` file to the latest version. Then, re-install dependencies: |
|
117
|
|
|
118
|
```bash npm2yarn |
|
119
|
npm install |
|
120
|
``` |