﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32697	Older versions of Django insist on converting BigAutoField back to AutoField	Alexander Todorov	nobody	"I've added the following change to django-attachments:

{{{
 class AttachmentsConfig(AppConfig):
+    default_auto_field = 'django.db.models.BigAutoField'
     name = ""attachments""
     verbose_name = _(""Attachments"")
diff --git a/attachments/migrations/0006_alter_pk_to_BigAutoField.py b/attachments/migrations/0006_alter_pk_to_BigAutoField.py
new file mode 100644
index 0000000..ab840dd
--- /dev/null
+++ b/attachments/migrations/0006_alter_pk_to_BigAutoField.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.2 on 2021-04-27 20:18
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('attachments', '0005_object_id_charfield'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='attachment',
+            name='id',
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
+     
}}}


Since the release notes point out that in the future BigAutoField is to be the default and that new apps are already generated with BigAutoField I've decided to use that as the default value. The new migration will take care of existing installations. Or so I thought. 

In our test suite when running with Django < 3.2 (e.g. 3.1.8) `makemigrations` insists on reverting this field back to AutoField and it creates the following 3rd migration - `attachments/migrations/0007_auto_20210429_0400.py`:

{{{
# Generated by Django 3.1.8 on 2021-04-29 04:00

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('attachments', '0006_alter_pk_to_BigAutoField'),
    ]

    operations = [
        migrations.AlterField(
            model_name='attachment',
            name='id',
            field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
        ),
    ]
}}}


I wasn't able to figure out how to prevent this from happening or what's causing it but I see this as a problem. 

For example a downstream app which is using django-attachments will call `makemigrations` to adjust their own migrations at some point in time, which will result in unwanted (and maybe even undetected) migrations for django-attachments.
"	Bug	closed	Migrations	3.2	Normal	invalid			Unreviewed	0	0	0	0	0	0
