Opened 9 years ago
Last modified 9 years ago
#25833 closed New feature
Non-atomic migrations — at Initial Version
Reported by: | Ludwig Hähne | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Shai Berger | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Database transactions are always wrapped in transactions (on DBs that support transactional DDL like Postgres). Generally this is a good idea.
However, one can't do batched updates in data migrations which is essential for performing changes on big tables on a live DB:
http://pankrat.github.io/2015/django-migrations-without-downtimes/
It's also not possible to create indexes concurrently on Postgres from inside a transaction.
Therefore, I'd like to have support for non-atomic migrations in Django because it's pretty messy to work around not having proper support for that:
http://stackoverflow.com/questions/31247810/commit-manually-in-django-data-migration
I propose exempting specific migrations from being wrapped in a transaction by setting atomic = False
on the migration:
https://github.com/django/django/compare/master...Ableton:non-atomic-migrations
I'll open a pull request for this new feature in a bit.