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 1 commit
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 to use a swappable dependency on settings.AUTH_USER_MODEL.
This should be changed to remove the swappable dependency, set a fixed migration dependency
and remove the AUTH_USER_MODEL setting from the settings file. FacilityUser should be used
instead.
rtibbles marked this conversation as resolved.
Show resolved Hide resolved
rtibbles marked this conversation as resolved.
Show resolved Hide resolved

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