Writing a simple Phinx query but forgetting to call one of the save()/create()/update() leaves the migration log in an invalid state. The migration will fail with an error similar to the following.
RuntimeException: Migration has pending actions after execution!
However, Phinx will still write to the migration log as if the migration completed successfully. Subsequent migrations will not run the migration again, because it thinks it has already completed. Subsequent rollbacks will fail because the changes do not exist.
That exception gets thrown as part of the postFlightCheck on the AbstractMigration.php. The execution of the migration happens here:
where we have:
I would propose moving the preFlightCheck and postFlightCheck inside the environment->executeMigration function and so have the following set-up:
An added benefit to also fixing the above would be that one would now be able to utilize the migration direction in the preFlightCheck method similar to the postFlightCheck method.
Someone wants to make a PR for this?
Is is this BC enough or should we put this into the next major?
It must be BC safe because forgetting to call those methods is an error and will break your migration table. So nobody can be doing this successfully and relying on this behaviour. Enhancement is the wrong tag, this is a bug.