Ensure fixture operations only run if needed #6621
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR makes absolutely sure that the 004 fixture migrations are all only run if they are needed. This makes it safer to run
FORCE_MIGRATION=true npm start
, which forces each database and fixture migration to try to run.Each migration does its own check for itself. In most cases this is simply checking to see if the data is already correct. However, in the case of
updating sort_order
onposts_tags
I'm having to use an approximation. If every single value ofsort_order
is 0, then assume the migration hasn't run yet, if any value is not 0 then don't run.The main implication here is that if FORCE_MIGRATION is used for some reason, the 004 sort_order migration won't inadvertently go back and revert all the tag orders to be the same as the incremental id. It also won't change the
ghost-admin
secret for no reason.It just makes it a little safer to to run migrations.
When you run the tests for fixture migrations, you'll now see that every single one of the 8 changes has a test that shows that under a certain condition it won't do anything.
refs #6301