Skip to content

Commit

Permalink
Make UUID fields primary + convert to psql UUIDs (quick & dirty)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfischer-ch committed Jun 10, 2014
1 parent 1509614 commit e92581b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions djcelery/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from django.db.models import signals
from django.utils.translation import ugettext_lazy as _

from django_extensions.db.fields import PostgreSQLUUIDField as UUIDField

from celery import schedules
from celery import states
from celery.events.state import heartbeat_expires
Expand All @@ -21,7 +23,7 @@

class TaskMeta(models.Model):
"""Task result/status."""
task_id = models.CharField(_('task id'), max_length=255, unique=True)
task_id = UUIDField(editable=False, primary_key=True, verbose_name=_('task id'))
status = models.CharField(
_('state'),
max_length=50, default=states.PENDING, choices=TASK_STATE_CHOICES,
Expand Down Expand Up @@ -55,7 +57,7 @@ def __unicode__(self):

class TaskSetMeta(models.Model):
"""TaskSet result"""
taskset_id = models.CharField(_('group id'), max_length=255, unique=True)
taskset_id = UUIDField(editable=False, primary_key=True, verbose_name=_('group id'))
result = PickledObjectField()
date_done = models.DateTimeField(_('created at'), auto_now=True)
hidden = models.BooleanField(editable=False, default=False, db_index=True)
Expand Down Expand Up @@ -315,7 +317,7 @@ class TaskState(models.Model):
state = models.CharField(
_('state'), max_length=64, choices=TASK_STATE_CHOICES, db_index=True,
)
task_id = models.CharField(_('UUID'), max_length=36, unique=True)
task_id = UUIDField(editable=False, primary_key=True, verbose_name=_('UUID'))
name = models.CharField(
_('name'), max_length=200, null=True, db_index=True,
)
Expand Down

0 comments on commit e92581b

Please sign in to comment.