class Operation:
Known subclasses: django.contrib.postgres.operations.CreateExtension
, django.contrib.postgres.operations.ValidateConstraint
, django.db.migrations.operations.RunPython
, django.db.migrations.operations.RunSQL
, django.db.migrations.operations.SeparateDatabaseAndState
, django.contrib.postgres.operations.CollationOperation
, django.db.migrations.operations.fields.FieldOperation
, django.db.migrations.operations.models.IndexOperation
, django.db.migrations.operations.models.ModelOperation
Base class for migration operations.
It's responsible for both mutating the in-memory model state (see db/migrations/state.py) to represent what it performs, as well as actually performing it against a live database.
Note that some operations won't modify memory state at all (e.g. data copying operations), and some will need their modifications to be optionally specified by the user (e.g. custom Python code snippets)
Due to the way this class deals with deconstruction, it should be considered immutable.
Method | __new__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | allow_migrate_model |
Return whether or not a model may be migrated. |
Method | database_backwards |
Perform the mutation on the database schema in the reverse direction - e.g. if this were CreateModel, it would in fact drop the model's table. |
Method | database_forwards |
Perform the mutation on the database schema in the normal (forwards) direction. |
Method | deconstruct |
Return a 3-tuple of class import path (or just name if it lives under django.db.migrations), positional arguments, and keyword arguments. |
Method | describe |
Output a brief summary of what the action does. |
Method | reduce |
Return either a list of operations the actual operation should be replaced with or a boolean that indicates whether or not the specified operation can be optimized across. |
Method | references_field |
Return True if there is a chance this operation references the given field name, with an app label for accuracy. |
Method | references_model |
Return True if there is a chance this operation references the given model name (as a string), with an app label for accuracy. |
Method | state_forwards |
Take the state from the previous migration, and mutate it so that it matches what this migration would perform. |
Class Variable | atomic |
Undocumented |
Class Variable | elidable |
Undocumented |
Class Variable | reduces_to_sql |
Undocumented |
Class Variable | reversible |
Undocumented |
Class Variable | serialization_expand_args |
Undocumented |
Instance Variable | _constructor_args |
Undocumented |
Property | migration_name_fragment |
A filename part suitable for automatically naming a migration containing this operation, or None if not applicable. |
Return whether or not a model may be migrated.
This is a thin wrapper around router.allow_migrate_model() that preemptively rejects any proxy, swapped out, or unmanaged model.
django.contrib.postgres.operations.CreateCollation
, django.contrib.postgres.operations.CreateExtension
, django.contrib.postgres.operations.RemoveCollation
, django.contrib.postgres.operations.ValidateConstraint
, django.db.migrations.operations.AddConstraint
, django.db.migrations.operations.AddField
, django.db.migrations.operations.AddIndex
, django.db.migrations.operations.AlterField
, django.db.migrations.operations.AlterModelManagers
, django.db.migrations.operations.AlterModelOptions
, django.db.migrations.operations.AlterModelTable
, django.db.migrations.operations.AlterOrderWithRespectTo
, django.db.migrations.operations.CreateModel
, django.db.migrations.operations.DeleteModel
, django.db.migrations.operations.RemoveConstraint
, django.db.migrations.operations.RemoveField
, django.db.migrations.operations.RemoveIndex
, django.db.migrations.operations.RenameField
, django.db.migrations.operations.RenameModel
, django.db.migrations.operations.RunPython
, django.db.migrations.operations.RunSQL
, django.db.migrations.operations.SeparateDatabaseAndState
, django.db.migrations.operations.models.AlterTogetherOptionOperation
django.contrib.postgres.operations.CreateCollation
, django.contrib.postgres.operations.CreateExtension
, django.contrib.postgres.operations.RemoveCollation
, django.contrib.postgres.operations.ValidateConstraint
, django.db.migrations.operations.AddConstraint
, django.db.migrations.operations.AddField
, django.db.migrations.operations.AddIndex
, django.db.migrations.operations.AlterField
, django.db.migrations.operations.AlterModelManagers
, django.db.migrations.operations.AlterModelOptions
, django.db.migrations.operations.AlterModelTable
, django.db.migrations.operations.AlterOrderWithRespectTo
, django.db.migrations.operations.CreateModel
, django.db.migrations.operations.DeleteModel
, django.db.migrations.operations.RemoveConstraint
, django.db.migrations.operations.RemoveField
, django.db.migrations.operations.RemoveIndex
, django.db.migrations.operations.RenameField
, django.db.migrations.operations.RenameModel
, django.db.migrations.operations.RunPython
, django.db.migrations.operations.RunSQL
, django.db.migrations.operations.SeparateDatabaseAndState
, django.db.migrations.operations.models.AlterTogetherOptionOperation
django.contrib.postgres.operations.ValidateConstraint
, django.db.migrations.operations.AddConstraint
, django.db.migrations.operations.AddField
, django.db.migrations.operations.AddIndex
, django.db.migrations.operations.AlterField
, django.db.migrations.operations.AlterModelManagers
, django.db.migrations.operations.AlterModelOptions
, django.db.migrations.operations.AlterModelTable
, django.db.migrations.operations.AlterOrderWithRespectTo
, django.db.migrations.operations.CreateModel
, django.db.migrations.operations.DeleteModel
, django.db.migrations.operations.RemoveConstraint
, django.db.migrations.operations.RemoveField
, django.db.migrations.operations.RemoveIndex
, django.db.migrations.operations.RenameField
, django.db.migrations.operations.RenameModel
, django.db.migrations.operations.RunPython
, django.db.migrations.operations.RunSQL
, django.db.migrations.operations.SeparateDatabaseAndState
, django.contrib.postgres.operations.CollationOperation
, django.db.migrations.operations.models.AlterTogetherOptionOperation
django.contrib.postgres.operations.CreateCollation
, django.contrib.postgres.operations.CreateExtension
, django.contrib.postgres.operations.RemoveCollation
, django.contrib.postgres.operations.ValidateConstraint
, django.db.migrations.operations.AddConstraint
, django.db.migrations.operations.AddField
, django.db.migrations.operations.AddIndex
, django.db.migrations.operations.AlterField
, django.db.migrations.operations.AlterModelManagers
, django.db.migrations.operations.AlterModelOptions
, django.db.migrations.operations.AlterModelTable
, django.db.migrations.operations.AlterOrderWithRespectTo
, django.db.migrations.operations.CreateModel
, django.db.migrations.operations.DeleteModel
, django.db.migrations.operations.RemoveConstraint
, django.db.migrations.operations.RemoveField
, django.db.migrations.operations.RemoveIndex
, django.db.migrations.operations.RenameField
, django.db.migrations.operations.RenameModel
, django.db.migrations.operations.RunPython
, django.db.migrations.operations.RunSQL
, django.db.migrations.operations.SeparateDatabaseAndState
, django.db.migrations.operations.models.AlterTogetherOptionOperation
django.db.migrations.operations.fields.FieldOperation
, django.db.migrations.operations.models.ModelOperation
django.db.migrations.operations.AlterOrderWithRespectTo
, django.db.migrations.operations.fields.FieldOperation
, django.db.migrations.operations.models.AlterTogetherOptionOperation
Return True if there is a chance this operation references the given field name, with an app label for accuracy.
Used for optimization. If in doubt, return True.
django.db.migrations.operations.fields.FieldOperation
, django.db.migrations.operations.models.ModelOperation
Return True if there is a chance this operation references the given model name (as a string), with an app label for accuracy.
Used for optimization. If in doubt, return True; returning a false positive will merely make the optimizer a little less efficient, while returning a false negative may result in an unusable optimized migration.
django.contrib.postgres.operations.CreateExtension
, django.contrib.postgres.operations.ValidateConstraint
, django.db.migrations.operations.AddConstraint
, django.db.migrations.operations.AddField
, django.db.migrations.operations.AddIndex
, django.db.migrations.operations.AlterField
, django.db.migrations.operations.AlterModelManagers
, django.db.migrations.operations.AlterModelOptions
, django.db.migrations.operations.AlterModelTable
, django.db.migrations.operations.AlterOrderWithRespectTo
, django.db.migrations.operations.CreateModel
, django.db.migrations.operations.DeleteModel
, django.db.migrations.operations.RemoveConstraint
, django.db.migrations.operations.RemoveField
, django.db.migrations.operations.RemoveIndex
, django.db.migrations.operations.RenameField
, django.db.migrations.operations.RenameModel
, django.db.migrations.operations.RunPython
, django.db.migrations.operations.RunSQL
, django.db.migrations.operations.SeparateDatabaseAndState
, django.contrib.postgres.operations.CollationOperation
, django.db.migrations.operations.models.AlterTogetherOptionOperation
django.contrib.postgres.operations.CreateCollation
, django.contrib.postgres.operations.CreateExtension
, django.contrib.postgres.operations.RemoveCollation
, django.contrib.postgres.operations.ValidateConstraint
, django.db.migrations.operations.AddConstraint
, django.db.migrations.operations.AddField
, django.db.migrations.operations.AddIndex
, django.db.migrations.operations.AlterField
, django.db.migrations.operations.AlterModelManagers
, django.db.migrations.operations.AlterModelOptions
, django.db.migrations.operations.AlterModelTable
, django.db.migrations.operations.AlterOrderWithRespectTo
, django.db.migrations.operations.CreateModel
, django.db.migrations.operations.DeleteModel
, django.db.migrations.operations.RemoveConstraint
, django.db.migrations.operations.RemoveField
, django.db.migrations.operations.RemoveIndex
, django.db.migrations.operations.RenameField
, django.db.migrations.operations.RenameModel
, django.db.migrations.operations.models.AlterTogetherOptionOperation