www/apps/cloud/app/update-medusa/page.mdx
export const metadata = {
title: Cloud Best Practices: Update Medusa Application,
}
In this guide, you'll learn how to update your Medusa application that is deployed on Cloud.
<Note title="Looking for the general update guide?">Refer to the Update guide to learn how to update your Medusa application.
</Note>Medusa regularly releases new versions of the core application with bug fixes, performance improvements, and new features.
It's highly recommended to always keep your Medusa application up to date. You'll benefit from the latest improvements and security patches.
This section provides best practices for updating your Medusa application on Cloud and how to update your application in a safe manner.
It's strongly discouraged to push a new update directly to your production branch. While Medusa updates are generally safe and stable, it's always a good practice to test the update in a separate environment before deploying it to production.
By using a separate environment, you mitigate any unexpected issues that may arise during the update process. This way, you ensure that your customizations and configurations work correctly with the new version of Medusa.
The recommended approach is to create a long-lived environment, such as Staging. You can push the new update and test it thoroughly in a production-like environment before deploying it to production.
<Note title="Tip">Each environment has its own database, so you can safely update other environments and make data changes without affecting the production environment.
</Note>Alternatively, you can open a pull request to the production branch, which will create a preview environment. The preview environment allows you to test the update before merging it into the production branch.
When creating custom migrations, it's important to include both up and down methods. The up method should define the changes to be made to the database schema, while the down method should reverse those changes.
By including both methods, you can easily roll back database changes if you need to revert the application's update.
If you use the db:generate command to generate migrations, it will automatically create both up and down methods for you. If you're creating the migrations manually, you can learn more in the Migrations guide.
To update your Medusa application deployed on Cloud:
package.json, lock file (for example, yarn.lock), and any other affected files to the branch.
Then, you can access the environment's live deployment to test the update. You can also use the build and runtime logs of the environment to debug any issues that occur during the update process or testing.
Once you've thoroughly tested the update in your long-lived or preview environment, you can merge the changes into your production branch.
Medusa will automatically deploy the changes to the production environment. This will update the production's code and database.
If you encounter any issues after updating your deployed Medusa application, you can redeploy a previous deployment to roll back the code changes made by the update.
However, redeploying a previous deployment will not roll back the database changes made by the update. If you need to roll back the database changes, contact support for assistance.