-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Improvements to the migrations CLI and workflow #8060
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Skipped Deployments
|
|
Amazed that tests are passing already 🙄 |
/snapshot-this |
THE PR IS AVAILABLE FOR REVIEW. BUT, DO NOT MERGE. |
/snapshot-this |
/snapshot-this |
🚀 A snapshot release has been made for this PRTest the snapshots by updating your yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add [email protected] yarn add @medusajs/[email protected] yarn add [email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add [email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add [email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected] yarn add @medusajs/[email protected]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💪
const applyMigration = async (linkModuleOptions, revert = false) => { | ||
for (const moduleName of Object.keys(allModules)) { | ||
const moduleResolution = MedusaModule.getModuleResolutions(moduleName) | ||
const applyMigration = async ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: As we discussed, we can probably move this one outside the main function wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uses sharedContainer
and sharedConfig
from the upper scope. Should we pass them down as parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, just to lighten this function a bit to simplify reading and understanding
Lovely :) we might need to remove |
@olivermrbl Can be improved a lot, we need a visual logger for CLI commands and ditch Winston. Will get onto refactoring CLI output someday 💪 |
@thetutlage - in production envs the logger uses a json format. Maybe we want to test that the output isn't filled with these types of outputs:
|
Do you think it would be problematic to have few spaces at the beginning of the message? |
@srindom Yes, it will be filled with that. The ideal solution is to have helpers for these sort of outputs that has different behavior when the output is JSON. But for now, either we have to remove these lines or apply a filter when these logs are consumed by a logging service. |
Yes and I believe our logger can have a custom handler for message and strip the space on front of it |
It shouldn't block this PR, but think it would be good for us to look into a way to specify that a log message is just for aesthetic purposes - we could maybe just use the silly log level for it, but let's leave that for another time :) |
Alright. We are ready to merge this PR. I have updated the description explaining the breaking change. |
CC @olivermrbl @adrien2p Ready to be re-reviewed and merged |
packages/core/utils/src/modules-sdk/migration-scripts/migration-down.ts
Outdated
Show resolved
Hide resolved
@thetutlage, upon merging a PR, can I get you to prefix the commit message (and ideally the PR title) with a tag indicating the PR type |
@olivermrbl Sure. Should this one be |
@thetutlage, we don't have
|
Cool! |
Very nit, but can you use the lowercased version hehe. Just for consistency 😅 |
FIXES: CORE-2495
FIXES: CORE-2482
Breaking change
This PR revamps the migration commands to work as per the new setup. Here's how the migrations will
run
andrevert
moving forward.run
command will continue to work as it is. I have to redo the CLI UI for it, but the behavior will remain the same.revert
command can only be used for specific modules. You can no longer revert migrations without specifying the module name. Here's the reasoning for that.The goal of the
revert
command is to undo mistakes during development. We should not confuserevert
withrollback
, where the later one is used to rollback the database state to a previous version.Since, the
revert
command intent is highly tied to development and that too within a specific module, you will have to run it against a module as well. There is no globalrevert
anymore.Changelog
This PR revamps the migrations workflow and the CLI output entirely. Here's a summary of the changes.
npx medusa migrations run
andnpx medusa migrations revert
Breaking changes
The
revert
command has a breaking change that it requires one or more module names to perform the revert. It means, the action revert is not valid at the global/app level. It must be executed on a specific module.If you are developing a custom module, you can run the
revert
command for it as follows.# helloWorld is the moduleName npx medusa migrations revert helloWorld