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

Middleware to warn for unapplied migrations #1696

Closed
atodorov opened this issue May 25, 2020 · 0 comments · Fixed by #1752
Closed

Middleware to warn for unapplied migrations #1696

atodorov opened this issue May 25, 2020 · 0 comments · Fixed by #1752
Labels
€ 50 bounty See bounty-program milestone

Comments

@atodorov
Copy link
Member

atodorov commented May 25, 2020

Not applying migrations can break upgrades and we've already seen installations out in the wild which have upgraded their docker containers without applying the migrations. This can result in serious data loss going forward if users do not upgrade their installations properly.

Django already contains the base functionality that we need:

./manage.py showmigrations will show empty boxes [ ] in case a migration has not been applied.

It is possible to use call_command (see tcms/core/tests/test_set_domain.py) and then parse the output but preferably we can hunt down a specific function in Django that lists all of the migrations and can reuse it instead of relying on text parsing.

Then all of that should be bundled in a middleware, similar to CheckSettingsMiddleware (or even inside of it) and if there are unapplied migrations add warning to the request. It will be displayed in the browser.

Definition of Done:

  • Middleware implemented, preferably without using call_command. If this isn't possible directly I need explanation & justification in the PR discussion how Django counts the migrations and which are applied/which aren't and why it won't be possible to use Django's internals for what we need.
  • Tests added for the new middleware
  • CI pass
  • All code review passed & PR merged

Hints:

This issue is part of Kiwi TCMS open source bounty program. For more information see the link(s) in bounty-program milestone

@atodorov atodorov added the € 50 bounty See bounty-program milestone label May 25, 2020
@atodorov atodorov added this to the bounty-program milestone May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
€ 50 bounty See bounty-program milestone
Projects
None yet
1 participant