Conversation
| protected function configure() | ||
| { | ||
| $this | ||
| ->setName('mx:migrate') |
There was a problem hiding this comment.
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.
what happens when we add a completely new module does this return the "upgrade required" status?
There was a problem hiding this comment.
Yeah it does, but that’s OK
There was a problem hiding this comment.
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.
🤔 I will investigate this further
There was a problem hiding this comment.
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.
Magento\Framework\Console\Cli has constants for RETURN_SUCCESS and RETURN_FAILURE
tkotosz
left a comment
There was a problem hiding this comment.
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.
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.
| $output->writeln('<info>No setup:upgrade required.</info>'); | ||
| } | ||
|
|
||
| $phinx = new Process('bin/phinx migrate'); |
There was a problem hiding this comment.
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:upgradeis requiredFixes #4