django_evolution.models
Database models for tracking project schema history.
Classes
|
|
|
A field for loading and storing project signatures. |
|
|
|
Manage Version models. |
- class django_evolution.models.VersionManager(*args, **kwargs)
Bases:
Manager
Manage Version models.
This introduces a convenience function for finding the current Version model for the database.
- current_version(using=None)
Return the Version model for the current schema.
This will find the Version with both the latest timestamp and the latest ID. It’s here as a replacement for the old call to
latest()
, which only operated on the timestamp and would find the wrong entry if two had the same exact timestamp.
- __slotnames__ = []
- class django_evolution.models.SignatureField(verbose_name=None, name=None, primary_key=False, max_length=None, unique=False, blank=False, null=False, db_index=False, rel=None, default=<class 'django.db.models.fields.NOT_PROVIDED'>, editable=True, serialize=True, unique_for_date=None, unique_for_month=None, unique_for_year=None, choices=None, help_text='', db_column=None, db_tablespace=None, auto_created=False, validators=(), error_messages=None)
Bases:
TextField
A field for loading and storing project signatures.
This will handle deserializing any project signatures stored in the database, converting them into a
ProjectSignature
, and then writing a serialized version back to the database.- description = 'Signature'
- contribute_to_class(cls, name)
Perform operations when added to a class.
This will listen for when an instance is constructed in order to perform some initial work.
- value_to_string(obj)
Return a serialized string value from the field.
- Parameters
obj (
django.db.models.Model
) – The model instance.- Returns
The serialized string contents.
- Return type
- to_python(value)
Return a ProjectSignature value from the field contents.
- Parameters
value (
object
) – The current value assigned to the field. This might be serialized string content or aProjectSignature
instance.- Returns
The project signature stored in the field.
- Return type
django_evolution.signatures.ProjectSignature
- Raises
django.core.exceptions.ValidationError – The field contents are of an unexpected type.
- get_prep_value(value)
Return a prepared Python value to work with.
This simply wraps
to_python()
.- Parameters
value (
object
) – The current value assigned to the field. This might be serialized string content or aProjectSignature
instance.- Returns
The project signature stored in the field.
- Return type
django_evolution.signatures.ProjectSignature
- Raises
django.core.exceptions.ValidationError – The field contents are of an unexpected type.
- get_db_prep_value(value, connection, prepared=False)
Return a prepared value for use in database operations.
- Parameters
value (
object
) – The current value assigned to the field. This might be serialized string content or aProjectSignature
instance.connection (
django.db.backends.base.BaseDatabaseWrapper
) – The database connection to operate on.prepared (
bool
, optional) – Whether the value is already prepared for Python.
- Returns
The value prepared for database operations.
- Return type
- class django_evolution.models.Version(id, signature, when)
Bases:
Model
- signature
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- when
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django_evolution.models.VersionManager object>
- is_hinted()
Return whether this is a hinted version.
Hinted versions store a signature without any accompanying evolutions.
- Returns
True
if this is a hinted evolution.False
if it’s based on explicit evolutions.- Return type
- __str__()
Return str(self).
- evolutions
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- get_next_by_when(*, field=<django.db.models.fields.DateTimeField: when>, is_next=True, **kwargs)
- get_previous_by_when(*, field=<django.db.models.fields.DateTimeField: when>, is_next=False, **kwargs)
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class django_evolution.models.Evolution(id, version, app_label, label)
Bases:
Model
- version
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- app_label
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- label
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- __str__()
Return str(self).
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>
- version_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.