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.
This library consider add column with default operation is unsafe operation, it was actual for old versions that rewrite whole table to add default. New postgres versions changes only metadata so this operation is fast and can be considered as safe except cases when column added with default and not null that is not safe operation in case of django that use default only for filling data and drop db default after migration. Also adding column with default is much efficient operation than adding column and fulfill data manually.
In django 5.0 new db_default were added that assume add column with default (using db_default) is safe both for adding column with null and not null.
So in this MR whole approach to work with defaults were changed:
ZERO_DOWNTIME_MIGRATIONS_KEEP_DEFAULT=True
- safe operation, after migration no nulls can be presented in db, provide same behavior asdb_default
More details described in #62
changes:
ADD COLUMN DEFAULT NULL
to safe operation for code defaultADD COLUMN DEFAULT NOT NULL
to safe operation fordb_default
in django 5.0+ZERO_DOWNTIME_MIGRATIONS_KEEP_DEFAULT
settings and changedADD COLUMN DEFAULT NOT NULL
with this settings to safe operation for django<5.0