[Django] #36639: Add CI step to run makemigrations --check against test models

7 views
Skip to first unread message

Django

unread,
Oct 3, 2025, 6:33:56 PM (3 days ago) Oct 3
to django-...@googlegroups.com
#36639: Add CI step to run makemigrations --check against test models
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Type:
| Cleanup/optimization
Status: new | Component: Core
| (Other)
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
When adjusting or adding test models, it is easy to overlook adding
changes to the migration files.

We could add some sort of CI check for this. We'd want a script, not
changes in `django.test`, but here's a dirty version just to surface the
failures. It doesn't work with the parallel runner.

{{{#!diff
diff --git a/django/test/testcases.py b/django/test/testcases.py
index c587f770a6..b33d2cf627 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -1132,6 +1132,12 @@ class TransactionTestCase(SimpleTestCase):
cls._pre_setup()
cls._pre_setup_ran_eagerly = True

+ try:
+ call_command("makemigrations", "--check", verbosity=0)
+ except SystemExit:
+ call_command("makemigrations", "--check", verbosity=3)
+ raise
+
@classmethod
def tearDownClass(cls):
super().tearDownClass()
}}}

Gives as of 2514857e3fae831106832cca8823237801cf2cad:

{{{#!py
Migrations for 'db_functions':
db_functions/migrations/0003_article_id_author_id_decimalmodel_id_dtmodel_id_and_more.py
+ Add field id to article
+ Add field id to author
+ Add field id to decimalmodel
+ Add field id to dtmodel
+ Add field id to fan
+ Add field id to floatmodel
+ Add field id to integermodel
Full migrations file
'0003_article_id_author_id_decimalmodel_id_dtmodel_id_and_more.py':
# Generated by Django 6.1.dev20251003191637 on 2025-10-03 17:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('db_functions', '0002_create_test_models'),
]

operations = [
migrations.AddField(
model_name='article',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
migrations.AddField(
model_name='author',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
migrations.AddField(
model_name='decimalmodel',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
migrations.AddField(
model_name='dtmodel',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
migrations.AddField(
model_name='fan',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
migrations.AddField(
model_name='floatmodel',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
migrations.AddField(
model_name='integermodel',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
]
Migrations for 'migration_test_data_persistence':
migration_test_data_persistence/migrations/0003_unmanaged_alter_book_id.py
+ Create model Unmanaged
~ Alter field id on book
Full migrations file '0003_unmanaged_alter_book_id.py':
# Generated by Django 6.1.dev20251003191637 on 2025-10-03 17:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('migration_test_data_persistence', '0002_add_book'),
]

operations = [
migrations.CreateModel(
name='Unmanaged',
fields=[
('id', models.BigAutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
],
options={
'managed': False,
},
),
migrations.AlterField(
model_name='book',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
]
Migrations for 'postgres_tests':
postgres_tests/migrations/0003_alter_withsizearraymodel_field.py
~ Alter field field on withsizearraymodel
Full migrations file '0003_alter_withsizearraymodel_field.py':
# Generated by Django 6.1.dev20251003191637 on 2025-10-03 17:27

import postgres_tests.fields
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('postgres_tests', '0002_create_test_models'),
]

operations = [
migrations.AlterField(
model_name='withsizearraymodel',
name='field',
field=postgres_tests.fields.DummyArrayField(base_field='',
default=None, size=1),
preserve_default=False,
),
]
Migrations for 'sites_framework':
sites_framework/migrations/0002_alter_customarticle_managers_and_more.py
~ Change managers on customarticle
~ Change managers on exclusivearticle
~ Change managers on syndicatedarticle
~ Alter field id on customarticle
~ Alter field id on exclusivearticle
~ Alter field id on syndicatedarticle
Full migrations file '0002_alter_customarticle_managers_and_more.py':
# Generated by Django 6.1.dev20251003191637 on 2025-10-03 17:27

import django.contrib.sites.managers
import django.db.models.manager
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sites_framework', '0001_initial'),
]

operations = [
migrations.AlterModelManagers(
name='customarticle',
managers=[
('objects', django.db.models.manager.Manager()),
('on_site',
django.contrib.sites.managers.CurrentSiteManager('places_this_article_should_appear')),
],
),
migrations.AlterModelManagers(
name='exclusivearticle',
managers=[
('objects', django.db.models.manager.Manager()),
('on_site',
django.contrib.sites.managers.CurrentSiteManager()),
],
),
migrations.AlterModelManagers(
name='syndicatedarticle',
managers=[
('objects', django.db.models.manager.Manager()),
('on_site',
django.contrib.sites.managers.CurrentSiteManager()),
],
),
migrations.AlterField(
model_name='customarticle',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='exclusivearticle',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='syndicatedarticle',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
]
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36639>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 3, 2025, 9:03:08 PM (3 days ago) Oct 3
to django-...@googlegroups.com
#36639: Add CI step to run makemigrations --check against test models
--------------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Natalia Bidart):

* stage: Unreviewed => Accepted

Comment:

Thank you Jacob, this is a good idea. Shall we use a GitHub actions for
this?
--
Ticket URL: <https://code.djangoproject.com/ticket/36639#comment:1>

Django

unread,
Oct 4, 2025, 9:18:19 AM (2 days ago) Oct 4
to django-...@googlegroups.com
#36639: Add CI step to run makemigrations --check against test models
--------------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: James
Type: Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by James):

* owner: (none) => James
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36639#comment:2>

Django

unread,
Oct 4, 2025, 9:50:50 AM (2 days ago) Oct 4
to django-...@googlegroups.com
#36639: Add CI step to run makemigrations --check against test models
--------------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: James
Type: Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by James):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36639#comment:3>

Django

unread,
Oct 4, 2025, 10:51:42 AM (2 days ago) Oct 4
to django-...@googlegroups.com
#36639: Add CI step to run makemigrations --check against test models
--------------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: James
Type: Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by James):

Please review: https://github.com/django/django/pull/19920
--
Ticket URL: <https://code.djangoproject.com/ticket/36639#comment:4>

Django

unread,
Oct 4, 2025, 12:17:02 PM (2 days ago) Oct 4
to django-...@googlegroups.com
#36639: Add CI step to run makemigrations --check against test models
--------------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: James
Type: Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Jacob Walls):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36639#comment:5>
Reply all
Reply to author
Forward
0 new messages