Currently, if running the status command causes an exception to be thrown which bubbles all the way to the top without being caught (like an InvalidArgumentException caused by a missing phinx.yml file on the FileLocator.locate() call), the script's exit code is 1.
The problem is that this is the same code as when there are down migrations (as per my merged changes from this PR), meaning there is no way of determining whether there really are down migrations or the command failed entirely.
I did some digging and I see that Phinx is not catching exceptions at all, meaning its down to the SymfonyComponent\Console\Application.run() method to decide the exit code, and it exits with 1 if there was an uncaught exception with code 0 (the default exit code for a InvalidArgumentException).
The way I see it, we can either:
Phinx\Console\Command\Status.execute() method with a try/catch block and exit with a different code if an uncaught exception is (now) caught.execute method?).I'm happy submitting a PR to fix this, just need some instructions on which option to go for (or any other option I didn't consider).
Change the phinx error status code for down migrations from 1 to something else (maybe 3 since 2 is the code for missing migrations?).
@rquadling would you be willing to include this change in the 0.7 release if a PR was made?
A different error code makes sense.
Are you able to provide a patch with your suggested changes as PR?
it's been a while, but I should be able to come up with something.
turns our it was this easy: https://github.com/cakephp/phinx/pull/1325 :-)
Note that this change has not made it to the docs yet. They still report the exit codes as 1 and 2.
@courtney-miles would you like to change the docs for this?
Most helpful comment
it's been a while, but I should be able to come up with something.