From 9b419d8f33eabb6b280d5812f02ae495a0caf2d5 Mon Sep 17 00:00:00 2001 From: Hugo Rodger-Brown Date: Mon, 28 Sep 2020 15:36:58 +0100 Subject: [PATCH 1/2] Add missing TokenProxy migration Fixes #7554 --- .../authtoken/migrations/0003_tokenproxy.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 rest_framework/authtoken/migrations/0003_tokenproxy.py diff --git a/rest_framework/authtoken/migrations/0003_tokenproxy.py b/rest_framework/authtoken/migrations/0003_tokenproxy.py new file mode 100644 index 0000000000..79405a7c0f --- /dev/null +++ b/rest_framework/authtoken/migrations/0003_tokenproxy.py @@ -0,0 +1,25 @@ +# Generated by Django 3.1.1 on 2020-09-28 09:34 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('authtoken', '0002_auto_20160226_1747'), + ] + + operations = [ + migrations.CreateModel( + name='TokenProxy', + fields=[ + ], + options={ + 'verbose_name': 'token', + 'proxy': True, + 'indexes': [], + 'constraints': [], + }, + bases=('authtoken.token',), + ), + ] From bed5c802df1f89f625dcd37dcd947fe834ed16fe Mon Sep 17 00:00:00 2001 From: Hugo Rodger-Brown Date: Mon, 28 Sep 2020 16:20:04 +0100 Subject: [PATCH 2/2] Add a system check on CI to catch missing migrations --- .travis.yml | 1 + runchecks.py | 29 +++++++++++++++++++++++++++++ tox.ini | 4 ++++ 3 files changed, 34 insertions(+) create mode 100755 runchecks.py diff --git a/.travis.yml b/.travis.yml index c204c54604..e5a4d82a71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ matrix: - { python: "3.8", env: TOXENV=base } - { python: "3.8", env: TOXENV=lint } - { python: "3.8", env: TOXENV=docs } + - { python: "3.8", env: TOXENV=checks } - python: "3.8" env: TOXENV=dist diff --git a/runchecks.py b/runchecks.py new file mode 100755 index 0000000000..f5170250a0 --- /dev/null +++ b/runchecks.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +"""Basic script used to run django-admin checks in CI/tox.""" +from django.conf import settings +from django.core.management import execute_from_command_line + + +if __name__ == "__main__": + + # Minimal settings required to check for migrations + settings.configure( + SECRET_KEY = "not very secret in checks either", + DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": ":memory:" + } + }, + INSTALLED_APPS = [ + 'django.contrib.auth', + 'django.contrib.contenttypes', + "rest_framework.authtoken" + ] + ) + + print("Running basic Django system checks") + execute_from_command_line(["manage.py", "check"]) + + print("Checking for missing Django migrations") + execute_from_command_line(["manage.py", "makemigrations", "--dry-run", "--verbosity=3", "--check"]) diff --git a/tox.ini b/tox.ini index d5e769764b..93108980f1 100644 --- a/tox.ini +++ b/tox.ini @@ -46,6 +46,10 @@ deps = -rrequirements/requirements-codestyle.txt -rrequirements/requirements-testing.txt +[testenv:checks] +commands = + ./runchecks.py + [testenv:docs] skip_install = true commands = mkdocs build