-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor and add backward compatibility #59
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #59 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 188 195 +7
Branches 43 49 +6
=========================================
+ Hits 188 195 +7 ☔ View full report in Codecov by Sentry. |
72b5b42
to
7b133bd
Compare
7b133bd
to
f789884
Compare
81b0218
to
7fd2c49
Compare
I'm making some changes to pull out items that seem to need more discussion, and to skip the changes I made to hide internal methods and state. |
9241a06
to
ae8cffe
Compare
The refactor is significant. It needed to reorder operations to allow for calculating safety configuration and delays, but along the way cleaned up naming, the default configuration, and the categories calculated and output to the user. Rename the internal enums and enum items. Call the enum that represents the run mode of "strict", "nonstrict", or "disabled" Mode, with PEP8 compliant names of STRICT, NONSTRICT, and DISABLED. Call the enum that represents the when each migration is allowed to run When, with names of BEFORE_DEPLOY, AFTER_DEPLOY, and ALWAYS. Factor out the loops that walk the dependency tree to categorize the migrations into ready, delayed, and blocked. Remove the category of "protected" migrations and combine it with delayed. Refactor the model manager into a model queryset, and separate filtering the queryset from resolving the final data type. Only write and read SafeMigration records for migrations that are after_deploy and have a delay set. Only write SafeMigration records for migrations that are delayed, not blocked or ready, to preserve appropriate semantics for nonstrict mode. Special-case Safe.before_deploy, Safe.after_deploy, and Safe.always to be allowed as callables for backward compatiblity. Categorize ``Safe.after_deploy`` and ``Safe.always`` migrations as blocked if they depend on other blocked migrations. The earliest blocked migrations must still be a ``Safe.before_deploy`` migration that depends on a ``Safe.after_deploy`` migration. Change the default safe marking from ``Safe.after_deploy`` to ``Safe.always``, to be more reasonable for working with third-party apps that do not use django-safemigrate.
ae8cffe
to
0d72346
Compare
Just going to open anything from this up in much smaller PRs |
Fix #54
Fix #38
The refactor is significant. It needed to reorder operations to allow for calculating safety configuration and delays, but along the way cleaned up naming, the default configuration, and the categories calculated and output to the user.
Rename the internal enums and enum items. Call the enum that represents the run mode of "strict", "nonstrict", or "disabled" Mode, with PEP8 compliant names of STRICT, NONSTRICT, and DISABLED. Call the enum that represents the when each migration is allowed to run When, with names of BEFORE_DEPLOY, AFTER_DEPLOY, and ALWAYS.
Factor out the loops that walk the dependency tree to categorize the migrations into ready, delayed, and blocked. Remove the category of "protected" migrations and combine it with delayed.
Refactor the model manager into a model queryset, and separate filtering the queryset from resolving the final data type.
Only write and read SafeMigration records for migrations that are after_deploy and have a delay set.
Only write SafeMigration records for migrations that are delayed, not blocked or ready, to preserve appropriate semantics for nonstrict mode.
Special-case Safe.before_deploy, Safe.after_deploy, and Safe.always to be allowed as callables for backward compatiblity.
Categorize
Safe.after_deploy
andSafe.always
migrations as blocked if they depend on other blocked migrations. The earliest blocked migrations must still be aSafe.before_deploy
migration that depends on aSafe.after_deploy
migration.Change the default safe marking from
Safe.after_deploy
toSafe.always
, to be more reasonable for working with third-party apps that do not use django-safemigrate.