From 30fbeb43bb0368e84c6cab7f30ad2ae9253f2454 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Thu, 16 Aug 2018 15:52:24 -0400 Subject: [PATCH] fail CI if the change includes model changes that are missing migrations --- Makefile | 1 + awx/main/management/commands/check_migrations.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 awx/main/management/commands/check_migrations.py diff --git a/Makefile b/Makefile index 54d0c49be3..2f444a3c89 100644 --- a/Makefile +++ b/Makefile @@ -382,6 +382,7 @@ test: . $(VENV_BASE)/awx/bin/activate; \ fi; \ py.test -n auto $(TEST_DIRS) + awx-manage check_migrations --dry-run --check -n 'vNNN_missing_migration_file' test_combined: test_ansible test diff --git a/awx/main/management/commands/check_migrations.py b/awx/main/management/commands/check_migrations.py new file mode 100644 index 0000000000..50ea354960 --- /dev/null +++ b/awx/main/management/commands/check_migrations.py @@ -0,0 +1,12 @@ +from django.db import connections +from django.db.backends.sqlite3.base import DatabaseWrapper +from django.core.management.commands.makemigrations import Command as MakeMigrations + + +class Command(MakeMigrations): + + def execute(self, *args, **options): + settings = connections['default'].settings_dict.copy() + settings['ENGINE'] = 'sqlite3' + connections['default'] = DatabaseWrapper(settings) + return MakeMigrations().execute(*args, **options)