Skip to content
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

Ensure fixture operations only run if needed #6621

Merged
merged 1 commit into from
Mar 22, 2016

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Mar 21, 2016

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 on posts_tags I'm having to use an approximation. If every single value of sort_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

  • Make sure that every fixture operation has a check to ensure that it hasn't already run
  • E.g. The update of sort_order on posts_tags should only happen if there are no values which aren't a zero
    • This makes sure that we don't accidentally overwrite data on FORCE_MIGRATE
  • No need to try to set settings types if they are already correct
  • Only update the admin client if it needs it, else we're regenerating secrets each time

refs TryGhost#6301

- Make sure that every fixture operation has a check to ensure that it hasn't already run
- E.g. The update of sort_order on posts_tags should only happen if there are no values which aren't a zero
  - This makes sure that we don't accidentally overwrite data on FORCE_MIGRATE
- No need to try to set settings types if they are already correct
- Only update the admin client if it needs it, else we're regenerating secrets each time
sebgie added a commit that referenced this pull request Mar 22, 2016
Ensure fixture operations only run if needed
@sebgie sebgie merged commit c2d8436 into TryGhost:master Mar 22, 2016
@ErisDS ErisDS deleted the fixture-run-once branch March 22, 2016 14:25
ErisDS added a commit to ErisDS/Ghost that referenced this pull request Mar 24, 2016
refs TryGhost#6621, TryGhost#6622

- remove unneeded `return new Promise.resolve()` lines
- reduce code in tests
- improve quality of tests checking that all task functions are executed
- add missing test coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants