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

Update migration script to handle multiple migrations automatically #425 #430

Merged
merged 14 commits into from
Dec 9, 2024

Conversation

joelvdavies
Copy link
Collaborator

@joelvdavies joelvdavies commented Nov 25, 2024

Description

See #425. In its current form this PR replicates similar behaviour to alembic. New migrations can be added using

ims-migrate generate test_migration "Does nothing"

Then the last migration applied is stored inside the database, and looked up to determine which migrations need to be applied in order to reach a desired one e.g.

ims-migrate forward latest

Applies all unapplied forward migrations in a single transaction. (This asks first although it would be simple to add a -y and even do what others do with alembic and put this in the docker file on start up - but its only a single command now anyway.)

This should hopefully make it easier to to apply the required migrations in the right order without specifying a list of migrations to perform when its time to update production.

Notes

  • The changes applied outside of a transaction e.g. dropping collections still occurs outside of the transaction but will be applied after all of the migrations have inside so these operations will technically be out of order

Testing instructions

Add a set up instructions describing how the reviewer should test the code

  • Review code
  • Check Actions build
  • Review changes to test coverage
  • Test creating a new migration and migrating forward and backwards locally

Agile board tracking

Closes #425

@joelvdavies joelvdavies added the enhancement New feature or request label Nov 25, 2024
@joelvdavies joelvdavies self-assigned this Nov 25, 2024
Copy link

codecov bot commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 98.05825% with 2 lines in your changes missing coverage. Please review.

Project coverage is 97.89%. Comparing base (b742092) to head (b728441).
Report is 29 commits behind head on develop.

Files with missing lines Patch % Lines
inventory_management_system_api/migrations/base.py 88.23% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #430      +/-   ##
===========================================
- Coverage    97.92%   97.89%   -0.04%     
===========================================
  Files           45       48       +3     
  Lines         1594     1712     +118     
===========================================
+ Hits          1561     1676     +115     
- Misses          33       36       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joelvdavies joelvdavies force-pushed the improve-migration-script-#425 branch from feeac08 to b40a965 Compare November 26, 2024 15:27
@joelvdavies joelvdavies force-pushed the improve-migration-script-#425 branch from 4d90aec to cf0edc5 Compare November 27, 2024 10:53
Copy link
Contributor

@asuresh-code asuresh-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall and works well. Just have some comments to make on core.py and some minor ones for the test.

Copy link
Contributor

@asuresh-code asuresh-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some more minor docstring comments.

README.md Outdated Show resolved Hide resolved
@asuresh-code
Copy link
Contributor

Also, the base.py file is missing full stops in most of the docstring comments.

@joelvdavies joelvdavies requested a review from VKTB December 5, 2024 13:04
@joelvdavies joelvdavies marked this pull request as ready for review December 5, 2024 13:04
Base automatically changed from add-spares-field-#416 to develop December 5, 2024 16:44
asuresh-code
asuresh-code previously approved these changes Dec 6, 2024
README.md Outdated Show resolved Hide resolved
@joelvdavies joelvdavies merged commit 2930356 into develop Dec 9, 2024
8 checks passed
@joelvdavies joelvdavies deleted the improve-migration-script-#425 branch December 9, 2024 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve migration script for multiple migrations
3 participants