django_evolution.diff
Support for diffing project signatures.
Changed in version 2.2: Moved django_evolution.placeholders.NullFieldInitialCallback
into its own module.
Classes
|
Generates diffs between project signatures. |
- class django_evolution.diff.Diff(original_project_sig, target_project_sig)
Bases:
object
Generates diffs between project signatures.
The resulting diff is contained in two attributes:
self.changed = { app_label: { 'changed': { model_name : { 'added': [ list of added field names ] 'deleted': [ list of deleted field names ] 'changed': { field: [ list of modified property names ] }, 'meta_changed': { 'constraints': new value 'db_table_comment': new value 'indexes': new value 'index_together': new value 'unique_together': new value } } 'deleted': [ list of deleted model names ] } } self.deleted = { app_label: [ list of models in deleted app ] }
- __init__(original_project_sig, target_project_sig)
Initialize the object.
- Parameters:
original_project_sig (
django_evolution.signature.ProjectSignature
) – The original project signature for the diff.target_project_sig (
django_evolution.signature.ProjectSignature
) – The target project signature for the diff.
- is_empty(ignore_apps=True)
Return whether the diff is empty.
This is used to determine if both signatures are effectively equal. If
ignore_apps
is set, this will ignore changes caused by deleted applications.
- __str__()
Return a string description of the diff.
This will describe the changes found in the diff, for human consumption.
- Returns:
The string representation of the diff.
- Return type:
- evolution()
Return the mutations needed for resolving the diff.
This will attempt to return a hinted evolution, consisting of a series of mutations for each affected application. These mutations will convert the database from the original to the target signatures.
- Returns:
An ordered dictionary of mutations. Each key is an application label, and each value is a list of mutations for the application.
- Return type: