pyani icon indicating copy to clipboard operation
pyani copied to clipboard

Issue #378: Add `alembic` support for database migrations

Open baileythegreen opened this issue 3 years ago • 3 comments

This PR adds alembic for pyani, making it possible to upgrade and downgrade existing databases to accommodate otherwise breaking changes to the ORM, as with the addition of fastANI capabilities.

Closes #378.

Type of change

  • [ ] Bug fix (non-breaking change that fixes an issue)
  • [x] New feature (non-breaking change that adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality not to work as expected)
  • [x] This change requires a documentation update
  • [ ] This is a documentation update

Action Checklist

  • [x] Work on a single issue/concept (if there are multiple separate issues to address, please use a separate pull request for each)
  • [ ] Fork the pyani repository under your own account (please allow write access for repository maintainers)
  • [x] Set up an appropriate development environment (please see CONTRIBUTING.md)
  • [x] Create a new branch with a short, descriptive name
  • [x] Work on this branch
    • [x] style guidelines have been followed
    • [x] new code is commented, especially in hard-to-understand areas
    • [x] corresponding changes to documentation have been made
    • [x] tests for the change have been added that demonstrate the fix or feature works
  • [x] Test locally with pytest -v non-passing code will not be merged
  • [x] Rebase against origin/master
  • [x] Check changes with flake8 and black before submission
  • [x] Commit branch
  • [x] Submit pull request, describing the content and intent of the pull request
  • [ ] Request a code review
  • [ ] Continue the discussion at Pull requests section in the pyani repository

baileythegreen avatar Mar 28 '22 21:03 baileythegreen

Codecov Report

Merging #387 (582bdc4) into master (62949c4) will decrease coverage by 0.53%. The diff coverage is 63.95%.

@@            Coverage Diff             @@
##           master     #387      +/-   ##
==========================================
- Coverage   75.82%   75.28%   -0.54%     
==========================================
  Files          55       58       +3     
  Lines        3747     3917     +170     
==========================================
+ Hits         2841     2949     +108     
- Misses        906      968      +62     

codecov[bot] avatar Mar 28 '22 21:03 codecov[bot]

This PR is still missing tests for the --dry-run option and some investigation is needed to ensure it works as expected in a non-development environment (where pyani versiondb would not be called from a dev pyani directory, and so the requisite alembic config files would be located elsewhere.

baileythegreen avatar Mar 28 '22 21:03 baileythegreen

In the interest of having the database migration functionality merged sooner, I would suggest that tests for the --dry-run option here be made a separate issue. The --dry-run option is neither the main purpose of this issue, nor does the migration capability hinge upon the --dry-run working correctly.

baileythegreen avatar Mar 31 '22 12:03 baileythegreen