diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4f3edf8877c..9a613b60d34 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: diff --git a/docs/backend_architecture/upgrade.rst b/docs/backend_architecture/upgrade.rst index 4ba7e2c07fd..1a044e73738 100644 --- a/docs/backend_architecture/upgrade.rst +++ b/docs/backend_architecture/upgrade.rst @@ -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,