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

new linter: warn about missing backwards migrations in RunPython + patches #1774

Closed
atodorov opened this issue Jul 4, 2020 · 4 comments · Fixed by #1789
Closed

new linter: warn about missing backwards migrations in RunPython + patches #1774

atodorov opened this issue Jul 4, 2020 · 4 comments · Fixed by #1789
Labels
€ 20 bounty See bounty-program milestone € 50 bounty See bounty-program milestone

Comments

@atodorov
Copy link
Member

atodorov commented Jul 4, 2020

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:

Here's me explaining how to write pylint plugins:

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.

@atodorov atodorov added € 50 bounty See bounty-program milestone € 20 bounty See bounty-program milestone labels Jul 4, 2020
@atodorov atodorov added this to the bounty-program milestone Jul 4, 2020
@atodorov
Copy link
Member Author

atodorov commented Jul 4, 2020

@brymut want to take care of this in parallel with #1752 ?

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
@atodorov
Copy link
Member Author

@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
brymut added a commit to brymut/Kiwi that referenced this issue Jul 16, 2020
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
brymut added a commit to brymut/Kiwi that referenced this issue Jul 21, 2020
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
atodorov pushed a commit that referenced this issue Jul 30, 2020
brymut added a commit to brymut/Kiwi that referenced this issue Aug 3, 2020
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
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
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
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
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
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
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
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
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
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
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
Copy link
Contributor

brymut commented Aug 19, 2020

@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
€ 20 bounty See bounty-program milestone € 50 bounty See bounty-program milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants