Skip to content

Commit

Permalink
Merge pull request #11989 from rtibbles/no_swappable_auth
Browse files Browse the repository at this point in the history
Add pre-commit hook and documentation to prevent swappable model dependencies
  • Loading branch information
marcellamaki committed Apr 4, 2024
2 parents ac7ed7c + a12f7cd commit a54107c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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

0 comments on commit a54107c

Please sign in to comment.