-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add migrate command #7
base: master
Are you sure you want to change the base?
Conversation
protected function configure() | ||
{ | ||
$this | ||
->setName('mx:migrate') |
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.
maybe phinx:db:migrate or mx:phinx:migrate would be a better name (in case any other inviqa/mx module introduces new commands under "mx:"
$dbStatusCommand = $this->getApplication()->get('setup:db:status'); | ||
|
||
$output->writeln('<info>Checking if setup:upgrade is required...</info>'); | ||
$exit = $dbStatusCommand->run(new ArrayInput([]), new NullOutput()); |
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.
what happens when we add a completely new module does this return the "upgrade required" status?
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.
Yeah it does, but that’s OK
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 just tested it by creating a new module in the src folder and the setup:db:status
says everything is up to date, while the new module is obviously not registered in the database yet. 🤔
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 will investigate this further
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.
From testing you are right, the setup:db:status
command only tells us if the DB has out-of-date modules and not if it is completely missing a module. Will have to look at something bespoke for this I think.
echo $buffer; | ||
}); | ||
|
||
return $phinx->isSuccessful() ? 0 : 1; |
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.
Magento\Framework\Console\Cli has constants for RETURN_SUCCESS and RETURN_FAILURE
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.
Generally looks good, but I have left some feedback. :)
if ($exit === DbStatusCommand::EXIT_CODE_UPGRADE_REQUIRED) { | ||
$output->writeln('<info>A setup:upgrade is required, running...</info>'); | ||
$setupUpgradeCommand = $this->getApplication()->get('setup:upgrade'); | ||
$setupUpgradeCommand->run(new ArrayInput([]), $output); |
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.
Normally after a production deployment we need to run setup:upgrade with the "--keep-generated" option, because in production mode we compile the di and deploy it with the code to production which we don't want to loose ofc.
So this migrate command should be able to accept a "--keep-generated" option as well and pass it over to the setup:upgrade here.
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.
Nice catch
$output->writeln('<info>No setup:upgrade required.</info>'); | ||
} | ||
|
||
$phinx = new Process('bin/phinx migrate'); |
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.
maybe use vendor/robmorgan/phinx/bin/phinx migrate
here in case "bin-dir": "bin"
is not specified in the project json (so it won't appear in the bin folder) ?
setup:upgrade
is requiredFixes #4