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

Add pre-commit hook and documentation to prevent swappable model dependencies #11989

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ repos:
kolibri/core/logger/migrations/0003_auto_20170531_1140\.py|
kolibri/core/logger/migrations/0005_auto_20180514_1419\.py|
)$
- id: no-swappable-auth-migrations
name: No migrations with swappable auth models (settings.AUTH_USER_MODEL)
entry: settings\.AUTH_USER_MODEL
language: pygrep
files: migrations/.*\.py$
- repo: https://github.com/isidentical/teyit
rev: 0.4.3
hooks:
Expand Down
6 changes: 6 additions & 0 deletions docs/backend_architecture/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ that take a ``choices`` keyword argument, where the choices are strings. The
strings should have no prefix (``u`` or ``b``) and the migration should contain
``from __future__ import unicode_literals`` as an import.

For any migrations involving Foreign keys to the FacilityUser model, the migration
will automatically be generated by Django to use a swappable dependency on settings.AUTH_USER_MODEL.
This should be updated by removing the swappable dependency, setting a fixed migration dependency
and replacing the reference to `settings.AUTH_USER_MODEL` with `"kolibriauth.FacilityUser"`
instead. For an example of this, see this previous pull request: https://github.com/learningequality/kolibri/pull/11984 .

We also use the upgrade functionality triggered during the CLI
initialization to copy in new copies of static files that are used in the frontend
app. These upgrades are only triggered for a subset of our CLI commands - start,
Expand Down
Loading