-
Notifications
You must be signed in to change notification settings - Fork 693
fix: add missing migration for token_blacklist app #894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vgrozdanic
merged 4 commits into
jazzband:master
from
juanbailon:fix/token-blacklist-migration
Apr 28, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
942192f
fix: add missing migration for token_blacklist app
juanbailon fdd288b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b28e9d1
test: Add check for ungenerated migrations
juanbailon 8687c19
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...work_simplejwt/token_blacklist/migrations/0013_alter_blacklistedtoken_options_and_more.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 5.1.7 on 2025-03-23 06:56 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("token_blacklist", "0012_alter_outstandingtoken_user"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="blacklistedtoken", | ||
options={ | ||
"verbose_name": "Blacklisted Token", | ||
"verbose_name_plural": "Blacklisted Tokens", | ||
}, | ||
), | ||
migrations.AlterModelOptions( | ||
name="outstandingtoken", | ||
options={ | ||
"ordering": ("user",), | ||
"verbose_name": "Outstanding Token", | ||
"verbose_name_plural": "Outstanding Tokens", | ||
}, | ||
), | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from io import StringIO | ||
from typing import Optional | ||
|
||
import pytest | ||
from django.core.management import call_command | ||
from django.test import TestCase | ||
|
||
|
||
class MigrationTestCase(TestCase): | ||
def test_no_missing_migrations(self): | ||
""" | ||
Ensures all model changes are reflected in migrations. | ||
If this test fails, there are model changes that require a new migration. | ||
|
||
Behavior: | ||
- Passes silently if no migrations are required | ||
- Fails with a detailed message if migrations are need | ||
""" | ||
|
||
output = StringIO() | ||
|
||
# Initialize exception variable to track migration check result | ||
exec: Optional[SystemExit] = None | ||
|
||
try: | ||
# Check for pending migrations without actually creating them | ||
call_command( | ||
"makemigrations", "--check", "--dry-run", stdout=output, stderr=output | ||
) | ||
except SystemExit as e: | ||
# Capture the SystemExit if migrations are needed (the command will had ended with exit code 1) | ||
exec = e | ||
|
||
# If an exception was raised, verify it indicates no migration changes are required | ||
if exec is not None: | ||
self.assertEqual( | ||
exec.code, | ||
0, # 0 means no migrations needed | ||
f"Model changes detected that require migrations!\n" | ||
f"Please run `python manage.py makemigrations` to create the necessary migrations.\n\n" | ||
f"Detected Changes:\n{output.getvalue()}", | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice solution, thank you!