Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unique constraint on UnitRespondingAgency #326

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions payroll/migrations/0026_unique_unitrespondingagency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 2.0.2 on 2019-03-04 22:25

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('payroll', '0025_rename_education_taxonomy'),
]

operations = [
migrations.AlterUniqueTogether(
name='unitrespondingagency',
unique_together={('unit', 'reporting_year')},
),
]
5 changes: 5 additions & 0 deletions payroll/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ class UnitRespondingAgency(models.Model):
'''
Associate units and responding agencies for a given year, so data from
that year can be linked to a specific source file.

There should only be one responding agency per unit, per year.
'''
unit = models.ForeignKey(
'Employer',
Expand All @@ -285,6 +287,9 @@ class UnitRespondingAgency(models.Model):
)
reporting_year = models.IntegerField()

class Meta:
unique_together = ('unit', 'reporting_year')


class EmployerTaxonomy(models.Model):
'''
Expand Down