-
-
Notifications
You must be signed in to change notification settings - Fork 299
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
new linter: warn about missing backwards migrations in RunPython + patches #1774
Labels
Milestone
Comments
brymut
added a commit
to brymut/pylint-django
that referenced
this issue
Jul 6, 2020
brymut
added a commit
to brymut/pylint-django
that referenced
this issue
Jul 8, 2020
brymut
added a commit
to brymut/pylint-django
that referenced
this issue
Jul 8, 2020
brymut
added a commit
to brymut/pylint-django
that referenced
this issue
Jul 9, 2020
brymut
added a commit
to brymut/pylint-django
that referenced
this issue
Jul 9, 2020
brymut
added a commit
to brymut/pylint-django
that referenced
this issue
Jul 9, 2020
brymut
added a commit
to brymut/pylint-django
that referenced
this issue
Jul 10, 2020
brymut
added a commit
to brymut/pylint-django
that referenced
this issue
Jul 10, 2020
brymut
added a commit
to brymut/pylint-django
that referenced
this issue
Jul 10, 2020
brymut
added a commit
to brymut/pylint-django
that referenced
this issue
Jul 11, 2020
atodorov
pushed a commit
to pylint-dev/pylint-django
that referenced
this issue
Jul 12, 2020
@brymut pylint-django v2.1.0 contains your new checker so you can deal with the rest of this issue. |
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Jul 12, 2020
…s migrations callable in RunPython
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Jul 16, 2020
…s migrations callable in RunPython
atodorov
added a commit
that referenced
this issue
Jul 18, 2020
this test rollbacks the migrations in the reverse order compared to when they were applied b/c there are dependencies between the apps. We should probably test migrating to 'zero' for each of the main apps to discover more issues about the migrations.
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Jul 19, 2020
…grations callable in RunPython
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Jul 21, 2020
…grations callable in RunPython
atodorov
added a commit
that referenced
this issue
Jul 25, 2020
this test rollbacks the migrations in the reverse order compared to when they were applied b/c there are dependencies between the apps. We should probably test migrating to 'zero' for each of the main apps to discover more issues about the migrations.
atodorov
added a commit
that referenced
this issue
Jul 25, 2020
this test rollbacks the migrations in the reverse order compared to when they were applied b/c there are dependencies between the apps. We should probably test migrating to 'zero' for each of the main apps to discover more issues about the migrations.
atodorov
added a commit
that referenced
this issue
Jul 25, 2020
this test rollbacks the migrations in the reverse order compared to when they were applied b/c there are dependencies between the apps. We should probably test migrating to 'zero' for each of the main apps to discover more issues about the migrations.
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Jul 29, 2020
…grations callable in RunPython
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 3, 2020
…cept for migration names
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 13, 2020
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 13, 2020
…purpose made `RunPython.noop()`
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 13, 2020
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 13, 2020
…purpose made `RunPython.noop()`
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 13, 2020
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 13, 2020
…purpose made `RunPython.noop()`
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
…purpose made `RunPython.noop()`
brymut
pushed a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
… fields in case the migration is applied backwards NOTES: - Can't use obj.serialize() b/c apps.get_model() retruns a fake class, not the real one. Fields are there but methods aren't. - Use Serializer(model=...).serialize_model() instead - ^^^ doesn't fail on previous migrations b/c the respective tables are empty during test! Will fail as soon as we have some records inside of them - Make `validate_reg_exp` and `url_reg_exp` fields nullable before removing them so that in the reverse direction the values could be restored and finally the fields set to NOT NULL once again!
brymut
pushed a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
… fields in case the migration is applied backwards NOTES: - Can't use obj.serialize() b/c apps.get_model() retruns a fake class, not the real one. Fields are there but methods aren't. - Use Serializer(model=...).serialize_model() instead - ^^^ doesn't fail on previous migrations b/c the respective tables are empty during test! Will fail as soon as we have some records inside of them - Make `validate_reg_exp` and `url_reg_exp` fields nullable before removing them so that in the reverse direction the values could be restored and finally the fields set to NOT NULL once again!
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
…purpose made `RunPython.noop()`
brymut
pushed a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
… fields in case the migration is applied backwards NOTES: - Can't use obj.serialize() b/c apps.get_model() retruns a fake class, not the real one. Fields are there but methods aren't. - Use Serializer(model=...).serialize_model() instead - ^^^ doesn't fail on previous migrations b/c the respective tables are empty during test! Will fail as soon as we have some records inside of them - Make `validate_reg_exp` and `url_reg_exp` fields nullable before removing them so that in the reverse direction the values could be restored and finally the fields set to NOT NULL once again!
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
…purpose made `RunPython.noop()`
brymut
pushed a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
… fields in case the migration is applied backwards NOTES: - Can't use obj.serialize() b/c apps.get_model() retruns a fake class, not the real one. Fields are there but methods aren't. - Use Serializer(model=...).serialize_model() instead - ^^^ doesn't fail on previous migrations b/c the respective tables are empty during test! Will fail as soon as we have some records inside of them - Make `validate_reg_exp` and `url_reg_exp` fields nullable before removing them so that in the reverse direction the values could be restored and finally the fields set to NOT NULL once again!
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
…purpose made `RunPython.noop()`
brymut
pushed a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
… fields in case the migration is applied backwards NOTES: - Can't use obj.serialize() b/c apps.get_model() retruns a fake class, not the real one. Fields are there but methods aren't. - Use Serializer(model=...).serialize_model() instead - ^^^ doesn't fail on previous migrations b/c the respective tables are empty during test! Will fail as soon as we have some records inside of them - Make `validate_reg_exp` and `url_reg_exp` fields nullable before removing them so that in the reverse direction the values could be restored and finally the fields set to NOT NULL once again!
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
…purpose made `RunPython.noop()`
brymut
pushed a commit
to brymut/Kiwi
that referenced
this issue
Aug 17, 2020
… fields in case the migration is applied backwards NOTES: - Can't use obj.serialize() b/c apps.get_model() retruns a fake class, not the real one. Fields are there but methods aren't. - Use Serializer(model=...).serialize_model() instead - ^^^ doesn't fail on previous migrations b/c the respective tables are empty during test! Will fail as soon as we have some records inside of them - Make `validate_reg_exp` and `url_reg_exp` fields nullable before removing them so that in the reverse direction the values could be restored and finally the fields set to NOT NULL once again!
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 18, 2020
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 18, 2020
…purpose made `RunPython.noop()`
brymut
pushed a commit
to brymut/Kiwi
that referenced
this issue
Aug 18, 2020
… fields in case the migration is applied backwards NOTES: - Can't use obj.serialize() b/c apps.get_model() retruns a fake class, not the real one. Fields are there but methods aren't. - Use Serializer(model=...).serialize_model() instead - ^^^ doesn't fail on previous migrations b/c the respective tables are empty during test! Will fail as soon as we have some records inside of them - Make `validate_reg_exp` and `url_reg_exp` fields nullable before removing them so that in the reverse direction the values could be restored and finally the fields set to NOT NULL once again!
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 18, 2020
brymut
added a commit
to brymut/Kiwi
that referenced
this issue
Aug 18, 2020
…purpose made `RunPython.noop()`
brymut
pushed a commit
to brymut/Kiwi
that referenced
this issue
Aug 18, 2020
… fields in case the migration is applied backwards NOTES: - Can't use obj.serialize() b/c apps.get_model() retruns a fake class, not the real one. Fields are there but methods aren't. - Use Serializer(model=...).serialize_model() instead - ^^^ doesn't fail on previous migrations b/c the respective tables are empty during test! Will fail as soon as we have some records inside of them - Make `validate_reg_exp` and `url_reg_exp` fields nullable before removing them so that in the reverse direction the values could be restored and finally the fields set to NOT NULL once again!
@atodorov submitted new expense on https://opencollective.com/kiwitcms/expenses/23852 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
migrations.RunPython()
is used to manipulate the DB in an arbitrary way. Usually adding initial data and sometimes renaming fields, etc.In several places we have a Python migration which doesn't have its backwards/reverse counterpart. This means these migrations cannot be rolled back.
A new linter is needed which will be executed against the migration files (pylint-django excludes migrations by default) and warn about this situation.
Definition of Done:
new checker class under https://github.com/PyCQA/pylint-django
If the linter sees a RunPython migration without its reverse part then warn
^^^ this will be developed in the pylint-django repository, also see https://github.com/PyCQA/pylint-django/blob/master/pylint_django/checkers/db_performance.py for hints. Assign
@atodorov
for code review.Then after a new pylint-django version has been released the new checker should be enabled against Kiwi TCMS migrations and all warnings from it should be fixed
All code review passed & PR merged
Here's me explaining how to write pylint plugins:
node_is_subclass
from pylint-django (which we use anyway) https://github.com/PyCQA/pylint-django/blob/master/pylint_django/utils.py - may help.This issue is part of Kiwi TCMS open source bounty program. For more information see the link(s) in bounty-program milestone
Note: this is a 70 EUR bounty issue.
The text was updated successfully, but these errors were encountered: