Skip to content

Commit

Permalink
Add unique_together on completed work model, migration
Browse files Browse the repository at this point in the history
  • Loading branch information
pxwxnvermx committed Dec 16, 2024
1 parent afea4f6 commit ced6c18
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2.5 on 2024-12-16 13:02

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("opportunity", "0062_opportunityaccess_invited_date"),
]

operations = [
migrations.AlterUniqueTogether(
name="completedwork",
unique_together={("entity_id", "payment_unit")},
),
]
3 changes: 3 additions & 0 deletions commcare_connect/opportunity/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ class CompletedWork(models.Model):
status_modified_date = models.DateTimeField(null=True)
payment_date = models.DateTimeField(null=True)

class Meta:
unique_together = ("entity_id", "payment_unit")

def __init__(self, *args, **kwargs):
self.status = CompletedWorkStatus.incomplete
self.status_modified_date = now()
Expand Down

0 comments on commit ced6c18

Please sign in to comment.