Version Field that returns a “unique” version number for the record.
The version number is produced using time.time() * 1000000, to get the benefits of microsecond if the system clock provides them.
Version Field increment the revision number each commit
This field use a database trigger to update the version field.
Using this you can control external updates (ie using tools like phpMyAdmin, pgAdmin, SQLDeveloper).
The trigger is automatically created during
or you can use the triggers management command.
Before django-concurrency 1.0 two triggers per field were created, if you are upgrading you must manually remove old triggers and recreate them using triggers management command
Starting from 1.0 you can customize the name of the trigger created. Otherwise for each TriggerVersionField will be created two triggers named:
Any name will be automatically prefixed with
Helper command to work with triggers:
list: list existing triggers for each database
drop: drop exisitng triggers
create: create required triggers
sax@: (concurrency) django-concurrency [feature/triggers*] $ ./demo/manage.py triggers create DATABASE TRIGGERS default concurrency_concurrency_triggerconcurrentmodel_u
This field allow to configure which fields trigger the version increment so to limit the scope of the concurrency checks.
class User(models.Model): version = ConditionalVersionField() username = models.CharField(...) password = models.PasswordField(...) class ConcurrencyMeta: check_fields = ('username',)