All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Enhanced
SaferAddUniqueConstraint
to support aUniqueConstraint
with thedeferrable
argument. - A new operation to remove a foreign key field:
SaferRemoveFieldForeignKey
. - A new operation
SaferRemoveCheckConstraint
which does the opposite ofSaferAddCheckConstraint
.
- A new type of index
UniqueIndex
that also accepts conditions. - A new operation to add one-to-one fields in a safer way:
SaferAddFieldOneToOne
.
- The
migrate_with_timeouts
command now acquires a session-level advisory lock before it begins. This helps preventing concurrent instances of the migrate command from running at the same time, which could cause unexpected crashes.
- A new operation to add a check constraint to an existing table has been
added:
SaferAddCheckConstraint
.
- Introspection queries are now skipped when running
sqlmigrate
. The result of thesqlmigrate
command will instead show a best-effort plan to perform the migration without knowing the current state of the database. When runningmigrate
, however, the introspection queries will find the most adequate plan; taking into consideration idempotency and reentrancy.
- Use
schema_editor
instead of opening a new cursor for executing DDL queries. This is so thatsqlmigrate
can show the queries without actually running them.
- Fixed a bug preventing the
SaferAddFieldForeignKey
operation of being initialised with ato
argument that is a string instead of models.Model
- A new operation to add foreign key fields to an existing table has been
added:
SaferAddFieldForeignKey
- The
migrate_with_timeouts
callback argumentRetryState
now includes the name of the database that the retry being performed is associated with.
- Fixed an import error introduced on v0.1.9 that would break that version for users of psycopg2.
- The
SaferAlterFieldSetNotNull
operation was added. This will more safely change a field from nullable to not nullable.
- Fixed a bug where
SaferAddUniqueConstraint
andSaferRemoveUniqueConstraint
would accept unique constraints with conditions on them, but produce invalid SQL. Unique constraints with conditions are now handled as partial unique indexes, as per the equivalent DjangoAddConstraint
andRemoveConstraint
operations.
SaferRemoveUniqueConstraint
operation was added. This is the complement forSaferAddUniqueConstraint
- but with the forward and backwards operations swapped.
- Fixes a bug in
migrate_with_timeouts
where passing astdout
parameter to the command would raise a TypeError.
migrate_with_timeouts
callbacks can now access the migration stdout viaRetryState.stdout
and the time since the migration started withRetryState.time_since_start
.- Added a new operation
SaferAddUniqueConstraint
that provides a way to safely create unique constraints.
migrate_with_timeouts
will now raiseMaximumRetriesReached
instead ofCommandError
when the maximum number of retries is reached.
- The implementation of
migrate_with_timeouts
now has additional flags to perform retries:./manage.py migrate_with_timeouts \ --lock-timeout-in-ms=10000 \ --lock-timeout-max-retries=3 \ --lock-timeout-retry-exp=2 \ --lock-timeout-retry-min-wait-in-ms=3000 \ --lock-timeout-retry-max-wait-in-ms=10000 \ --statement-timeout-in-ms=10000 \ --retry-callback-path="dotted.path.to.callback.function"
SaferRemoveIndexConcurrently
migration operation to drop Postgres indexes in a safer way than Django'sRemoveIndexConcurrently
.
- The internal implementation for
SaferAddIndexConcurrently
has been changed to inherit from Django'sAddIndexConcurrently
operation rather than Django'sOperation
class. This means that the interface is now the same and the "hints" argument is not valid any longer.
- Fixes a bug where the
SaferAddIndexConcurrently
class would try to perform a migration regardless of whether the router would allow it (throughrouter.allow_migrate
).
- Non-functional changes for the documentation to be properly linked in PyPI.
apply_timeouts
context manager for controlling the values of lock_timeout and statement_timeout.migrate_with_timeouts
management command that applies lock_timeout and statement_timeout to Django's migrate command.SaferAddIndexConcurrently
migration operation to create new Postgres indexes in a safer, idempotent way.