diff options
| author | Skyiesac <jainsachi1202@gmail.com> | 2026-01-19 12:45:29 -0500 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-01-20 10:40:53 -0500 |
| commit | e5cbb8b4be04797deedc775a5143b5035e7dd3b7 (patch) | |
| tree | b65f9a951669e77da04dce1f373cabd0490f1f08 /scripts | |
| parent | 748c2ba8370c66b098bd78b241c70d16712d1e93 (diff) | |
Fixed #36639 -- Added CI step to run makemigrations --check against test models.
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/check_migrations.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/check_migrations.py b/scripts/check_migrations.py new file mode 100644 index 0000000000..70d187e144 --- /dev/null +++ b/scripts/check_migrations.py @@ -0,0 +1,31 @@ +import sys +from pathlib import Path + + +def main(): + repo_root = Path(__file__).resolve().parent.parent + sys.path[:0] = [str(repo_root / "tests"), str(repo_root)] + + from runtests import ALWAYS_INSTALLED_APPS, get_apps_to_install, get_test_modules + + import django + from django.apps import apps + from django.core.management import call_command + + django.setup() + + test_modules = list(get_test_modules(gis_enabled=False)) + installed_apps = list(ALWAYS_INSTALLED_APPS) + for app in get_apps_to_install(test_modules): + # Check against the list to prevent duplicate errors. + if app not in installed_apps: + installed_apps.append(app) + apps.set_installed_apps(installed_apps) + + # Note: We don't use check=True here because --check calls sys.exit(1) + # instead of raising CommandError when migrations are missing. + call_command("makemigrations", "--check", verbosity=3) + + +if __name__ == "__main__": + main() |
