Hotfix: make news audience migration non-atomic - #701
Merged
Conversation
TThanos3000
marked this pull request as ready for review
August 21, 2026 07:18
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
news.0010_news_audience_newscommentmigration to dev withatomic = False.platform, program news toprogram_participants, and the samenews_valid_audienceconstraint /NewsCommentschema are created.News/NewsCommentmodel schema so dev runtime stays consistent after applying the migration.Why
atomic = FalseDjango documents this PostgreSQL failure mode for migrations that combine schema changes and
RunPythonin the same transaction: PostgreSQL can raisecannot ALTER TABLE ... because it has pending trigger events. Setting migration-levelatomic = Falseruns the migration operations outside one wrapping transaction. TheRunPythonoperation does not passatomic=True, so it does not reintroduce a transaction for this operation.Production retry safety
The failed production run used the old atomic migration and should have rolled back the whole
0010migration. Retrying with this changed migration should re-runAddField->RunPython->AddConstraint->CreateModelwithout hitting pending trigger events.Checks
DEBUG=True python manage.py test news.tests.test_news_migration_0010 --verbosity=2— passed; PostgreSQL-only regression skipped locally on sqlite.DEBUG=True python manage.py makemigrations --check --dry-run— passed, no changes detected.python -m flake8 news/models.py news/migrations/0010_news_audience_newscomment.py news/tests/test_news_migration_0010.py— passed.DEBUG=True python manage.py test news --verbosity=2— passed: 28 tests OK, 1 PostgreSQL-only regression skipped locally on sqlite.Not changed