Repository: jazzband/djangorestframework-simplejwt (language: python)

Issue:
Makemigrations create new migrations for models in token_blacklist app
Hello,

Everytime I try to run the migrations for my apps in django, new migrations are created for the token_blacklist applications. Is this how it's supposed to be?
Currently found on versions 4.5.0 and 4.6.0.
```
Your models in app(s): 'token_blacklist' have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
root@6d2b2b13006d:/app# python manage.py makemigrations
Migrations for 'token_blacklist':
  /usr/local/lib/python3.9/site-packages/rest_framework_simplejwt/token_blacklist/migrations/0008_auto_20210424_0948.py
    - Alter field id on blacklistedtoken
    - Alter field id on outstandingtoken
```


Discussion / hints:
I'm not sure where that's coming from. This may be due to new features in Django. What Django version are you using? Do you mind posting that new migration file? Thanks!
Sincere apologies for the tardiness I got caught up in personal errands.
Django version: 3.2
Migration file:
```
# Generated by Django 3.2 on 2021-05-02 18:44

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('token_blacklist', '0007_auto_20171017_2214'),
    ]

    operations = [
        migrations.AlterField(
            model_name='blacklistedtoken',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
        ),
        migrations.AlterField(
            model_name='outstandingtoken',
            name='id',
            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
        ),
    ]
```

Might have something to do with [this](https://docs.djangoproject.com/en/3.2/releases/3.2/#customizing-type-of-auto-created-primary-keys) latest Django 3.2 changelog I believe.

Appreciate your response! Thanks.
np about tardiness. It seems like that change definitely makes sense. Is there any database that doesn't support 8 bytes to store integers? Not sure if we want to define the AutoField, but then again it's technically already been defined as `AutoField` for a long time.

Do you mind telling me which database you're using? I have doubts about proper migration from AutoField to BigAutoField (especially after seeing this ticket: https://code.djangoproject.com/ticket/30266)
I'm using postgres 12. Running it as a docker image at the moment.
[Here](https://hub.docker.com/_/postgres)
Note: this happened due to Django 3.2 having a setting that can identify what the primary key field will be (i.e. either AutoField or BigAutoField). I think it's safe to say we can safely migrate to BigAutoField since Django used to have AutoField on by default but not it's BigAutoField as the default.
Okay. I can handle the migrations with some commands on application initializations for now. Willi you be adding the new migrations in your next release? I think I can work on it if you open this up as an issue and implement any other ideas if you might have regarding this Django settings change.
I have no issue with you creating a PR for this (considering I can't merge anything I create myself)! Can't guarantee if it'll be in the next release, but I think it can make it.

Just make sure you update the CHANGELOG under Version 4.7 alongside the migration file! In our settings.py file, it'd be great if you could add that setting that defaults id field to BigAutoField so in our tests we can avoid a CI warning.
Noted. I'll start working and I'll have a MR for you to review.
@Andrew-Chen-Wang I've set up the project and seems to be running fine. Could you direct me as to how I might be able to run the django commands to generate the migrations and run other related django commands? Maybe I've missed some instructions that are there so would appreciate the assistance. Thank you.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 29572d78b..a4732a881 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,41 +1,43 @@
-## Version 4.7
+## Version 4.7.0
 
-* Added Italian translations ([#342](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/342))
+* Added support for Django 3.2 ([#404](https://github.com/jazzband/django-rest-framework-simplejwt/pull/404))
+* Added Italian translations ([#342](https://github.com/jazzband/django-rest-framework-simplejwt/pull/342))
 * Fixed DRF app registry bug, specifically `django.core.exceptions.AppRegistryNotReady`
-  ([#331](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/331))
-* Fixed support for PyJWT>=2.0.0 ([#376](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/376))
+  ([#331](https://github.com/jazzband/django-rest-framework-simplejwt/pull/331))
+* Fixed support for PyJWT>=2.0.0 ([#376](https://github.com/jazzband/django-rest-framework-simplejwt/pull/376))
+* Migrated blacklist app models to use BigAutoField IDs for Django>=3.2. ([#404](https://github.com/jazzband/django-rest-framework-simplejwt/pull/404))
 
 ## Version 4.6
 
-* Added support for PyJWT>=2.0.0 ([#329](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/329))
-* Restored Python 3.7 support ([#332](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/332))
-* Added Indonesian translations ([#316](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/316))
-* Fixed Django 4.0 re_path deprecation ([#280](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/280))
+* Added support for PyJWT>=2.0.0 ([#329](https://github.com/jazzband/django-rest-framework-simplejwt/pull/329))
+* Restored Python 3.7 support ([#332](https://github.com/jazzband/django-rest-framework-simplejwt/pull/332))
+* Added Indonesian translations ([#316](https://github.com/jazzband/django-rest-framework-simplejwt/pull/316))
+* Fixed Django 4.0 re_path deprecation ([#280](https://github.com/jazzband/django-rest-framework-simplejwt/pull/280))
 
 ## Version 4.5
 
-* Added `AUTH_HEADER_NAME` to settings ([#309](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/309))
-* Added `USER_AUTHENTICATION_RULE` to settings ([#279](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/279))
-* Added `UPDATE_LAST_LOGIN` to settings ([#238](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/238))
-* Fixed packaging of locale folder for installation ([#117](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/117))
-* Allowed TokenUser to be configurable ([#172](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/172))
+* Added `AUTH_HEADER_NAME` to settings ([#309](https://github.com/jazzband/django-rest-framework-simplejwt/pull/309))
+* Added `USER_AUTHENTICATION_RULE` to settings ([#279](https://github.com/jazzband/django-rest-framework-simplejwt/pull/279))
+* Added `UPDATE_LAST_LOGIN` to settings ([#238](https://github.com/jazzband/django-rest-framework-simplejwt/pull/238))
+* Fixed packaging of locale folder for installation ([#117](https://github.com/jazzband/django-rest-framework-simplejwt/pull/117))
+* Allowed TokenUser to be configurable ([#172](https://github.com/jazzband/django-rest-framework-simplejwt/pull/172))
 * Dropped Python 3.7 and below (restored Python 3.7 but not 3.6 in next version) 
 * Improved error message if cryptography isn't installed
   when developer tries to use a certain algorithm that needs the package
-  ([#285](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/285))
-* Fixed Django 4.0 ugettext_lazy deprecation warnings ([#186](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/186))
-* Remove upper bound of Python version ([#225](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/225))
-* Added DRF 3.11 support ([#230](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/230))
+  ([#285](https://github.com/jazzband/django-rest-framework-simplejwt/pull/285))
+* Fixed Django 4.0 ugettext_lazy deprecation warnings ([#186](https://github.com/jazzband/django-rest-framework-simplejwt/pull/186))
+* Remove upper bound of Python version ([#225](https://github.com/jazzband/django-rest-framework-simplejwt/pull/225))
+* Added DRF 3.11 support ([#230](https://github.com/jazzband/django-rest-framework-simplejwt/pull/230))
 
 Translations:
-* Added French translations ([#314](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/314))
-* Added Spanish translations ([#294](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/294))
-* Added Argentinian Spanish translations ([#244](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/244))
-* Added Persian translations ([#220](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/220))
-* Added German translations ([#198](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/198))
-* Added Czech translations ([#188](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/188))
-* Added Polish translations ([#166](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/166))
-* Fixed incorrect language encoding from de_CH to es_CL ([#299](https://github.com/SimpleJWT/django-rest-framework-simplejwt/pull/299))
+* Added French translations ([#314](https://github.com/jazzband/django-rest-framework-simplejwt/pull/314))
+* Added Spanish translations ([#294](https://github.com/jazzband/django-rest-framework-simplejwt/pull/294))
+* Added Argentinian Spanish translations ([#244](https://github.com/jazzband/django-rest-framework-simplejwt/pull/244))
+* Added Persian translations ([#220](https://github.com/jazzband/django-rest-framework-simplejwt/pull/220))
+* Added German translations ([#198](https://github.com/jazzband/django-rest-framework-simplejwt/pull/198))
+* Added Czech translations ([#188](https://github.com/jazzband/django-rest-framework-simplejwt/pull/188))
+* Added Polish translations ([#166](https://github.com/jazzband/django-rest-framework-simplejwt/pull/166))
+* Fixed incorrect language encoding from de_CH to es_CL ([#299](https://github.com/jazzband/django-rest-framework-simplejwt/pull/299))
 
 ## Version 4.4
 
diff --git a/rest_framework_simplejwt/token_blacklist/migrations/0008_migrate_to_bigautofield.py b/rest_framework_simplejwt/token_blacklist/migrations/0008_migrate_to_bigautofield.py
new file mode 100644
index 000000000..dd218d24d
--- /dev/null
+++ b/rest_framework_simplejwt/token_blacklist/migrations/0008_migrate_to_bigautofield.py
@@ -0,0 +1,21 @@
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('token_blacklist', '0007_auto_20171017_2214'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='blacklistedtoken',
+            name='id',
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
+        ),
+        migrations.AlterField(
+            model_name='outstandingtoken',
+            name='id',
+            field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
+        ),
+    ]
diff --git a/rest_framework_simplejwt/token_blacklist/models.py b/rest_framework_simplejwt/token_blacklist/models.py
index a46131104..eb98c7cd1 100644
--- a/rest_framework_simplejwt/token_blacklist/models.py
+++ b/rest_framework_simplejwt/token_blacklist/models.py
@@ -3,6 +3,7 @@
 
 
 class OutstandingToken(models.Model):
+    id = models.BigAutoField(primary_key=True)
     user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True, blank=True)
 
     jti = models.CharField(unique=True, max_length=255)
@@ -28,6 +29,7 @@ def __str__(self):
 
 
 class BlacklistedToken(models.Model):
+    id = models.BigAutoField(primary_key=True)
     token = models.OneToOneField(OutstandingToken, on_delete=models.CASCADE)
 
     blacklisted_at = models.DateTimeField(auto_now_add=True)
diff --git a/tox.ini b/tox.ini
index 22b1bf1a2..6ffb99821 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,7 @@
 [tox]
 envlist=
     py{37,38,39}-dj{22,30}-drf310-tests
-    py{37,38,39}-dj{22,30,31}-drf{311,312}-tests
+    py{37,38,39}-dj{22,30,31,32}-drf{311,312}-tests
     py39-djmain-drf312-tests
     docs
     lint
@@ -17,6 +17,7 @@ DJANGO=
     2.2: dj22
     3.0: dj30
     3.1: dj31
+    3.2: dj32
     main: djmain
 DRF=
     3.10: drf310
@@ -35,6 +36,7 @@ deps=
     dj22: Django>=2.2,<2.3
     dj30: Django>=3.0,<3.1
     dj31: Django>=3.1,<3.2
+    dj32: Django>=3.2,<3.3
     drf310: djangorestframework>=3.10,<3.11
     drf311: djangorestframework>=3.11,<3.12
     drf312: djangorestframework>=3.12,<3.13


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 6529b9836..50980cb3b 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -11,7 +11,7 @@ jobs:
       max-parallel: 5
       matrix:
         python-version: ['3.7', '3.8', '3.9']
-        django-version: ['2.2', '3.0', '3.1', 'main']
+        django-version: ['2.2', '3.0', '3.1', '3.2', 'main']
         drf-version: ['3.10', '3.11', '3.12']
         exclude:
           - python-version: '3.7'
diff --git a/tests/test_token_blacklist.py b/tests/test_token_blacklist.py
index b0de226a4..58c4aca4d 100644
--- a/tests/test_token_blacklist.py
+++ b/tests/test_token_blacklist.py
@@ -2,6 +2,7 @@
 
 from django.contrib.auth.models import User
 from django.core.management import call_command
+from django.db.models import BigAutoField
 from django.test import TestCase
 
 from rest_framework_simplejwt.exceptions import TokenError
@@ -190,3 +191,17 @@ def test_jti_field_should_contain_uuid_hex_strings(self):
         actual_hexes = [i.jti_hex for i in OutstandingToken.objects.all()]
 
         self.assertEqual(actual_hexes, self.expected_hexes)
+
+
+class TestBigAutoFieldIDMigration(MigrationTestCase):
+    migrate_from = ('token_blacklist', '0007_auto_20171017_2214')
+    migrate_to = ('token_blacklist', '0008_migrate_to_bigautofield')
+
+    def test_outstandingtoken_id_field_is_biagauto_field(self):
+        OutstandingToken = self.apps.get_model('token_blacklist', 'OutstandingToken')
+        assert isinstance(OutstandingToken._meta.get_field('id'), BigAutoField)
+
+    def test_blacklistedtoken_id_field_is_biagauto_field(self):
+        BlacklistedToken = self.apps.get_model('token_blacklist', 'BlacklistedToken')
+        assert isinstance(BlacklistedToken._meta.get_field('id'), BigAutoField)
+