From e5cbb8b4be04797deedc775a5143b5035e7dd3b7 Mon Sep 17 00:00:00 2001 From: Skyiesac Date: Mon, 19 Jan 2026 12:45:29 -0500 Subject: Fixed #36639 -- Added CI step to run makemigrations --check against test models. --- scripts/check_migrations.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 scripts/check_migrations.py (limited to 'scripts') 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() -- cgit v1.3