Skip to content

Commit

Permalink
Fix migrate to bigautofield (#411)
Browse files Browse the repository at this point in the history
* Fixes #410
* Added #411 to CHANGELOG
* Delete unnecessary operations in 0011

Co-authored-by: Andrew Chen Wang <[email protected]>
  • Loading branch information
mom1 and Andrew-Chen-Wang authored May 28, 2021
1 parent c775d29 commit c890b70
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## Unreleased

## Version 4.7
## Version 4.7.1

* Fixed user-generated migration file bug in token_blacklist ([#410]((https://github.com/jazzband/django-rest-framework-simplejwt/pull/411)))

## Version 4.7.0

* Added support for Django 3.2 and drop Django 3.0 ([#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))
Expand Down
1 change: 1 addition & 0 deletions rest_framework_simplejwt/token_blacklist/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
class TokenBlacklistConfig(AppConfig):
name = 'rest_framework_simplejwt.token_blacklist'
verbose_name = _('Token Blacklist')
default_auto_field = 'django.db.models.BigAutoField'
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.3 on 2021-05-27 17:46

import os, fnmatch
from pathlib import Path

from django.db import migrations, models

parent_dir = Path(__file__).resolve(strict=True).parent


class Migration(migrations.Migration):

dependencies = [
('token_blacklist', '0008_migrate_to_bigautofield'),
]

operations = [
migrations.AlterField(
model_name='blacklistedtoken',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='outstandingtoken',
name='id',
field=models.BigAutoField(primary_key=True, serialize=False),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import fnmatch
import os
from pathlib import Path

from django.db import migrations, models

parent_dir = Path(__file__).resolve(strict=True).parent


class Migration(migrations.Migration):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.dependencies = [
('token_blacklist', '0010_fix_migrate_to_bigautofield')
]
_m = sorted(fnmatch.filter(os.listdir(parent_dir), "000*.py"))
if len(_m) == 9:
self.dependencies.insert(0, ('token_blacklist', os.path.splitext(_m[8])[0]))

operations = [
]
4 changes: 2 additions & 2 deletions rest_framework_simplejwt/token_blacklist/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class OutstandingToken(models.Model):
id = models.BigAutoField(primary_key=True)
id = models.BigAutoField(primary_key=True, serialize=False)
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True, blank=True)

jti = models.CharField(unique=True, max_length=255)
Expand All @@ -29,7 +29,7 @@ def __str__(self):


class BlacklistedToken(models.Model):
id = models.BigAutoField(primary_key=True)
id = models.BigAutoField(primary_key=True, serialize=False)
token = models.OneToOneField(OutstandingToken, on_delete=models.CASCADE)

blacklisted_at = models.DateTimeField(auto_now_add=True)
Expand Down

0 comments on commit c890b70

Please sign in to comment.