From a94599fca730e12d7b9f2afeda5776f8618960bb Mon Sep 17 00:00:00 2001 From: umkay Date: Mon, 31 Oct 2016 17:51:58 -0700 Subject: [PATCH] analytics/models.py: Add subgroup column to unique_together constraints. --- ...0006_add_subgroup_to_unique_constraints.py | 30 +++++++++++++++++++ analytics/models.py | 8 ++--- 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 analytics/migrations/0006_add_subgroup_to_unique_constraints.py diff --git a/analytics/migrations/0006_add_subgroup_to_unique_constraints.py b/analytics/migrations/0006_add_subgroup_to_unique_constraints.py new file mode 100644 index 0000000000..9898390ebb --- /dev/null +++ b/analytics/migrations/0006_add_subgroup_to_unique_constraints.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('analytics', '0005_alter_field_size'), + ] + + operations = [ + migrations.AlterUniqueTogether( + name='installationcount', + unique_together=set([('property', 'subgroup', 'end_time', 'interval')]), + ), + migrations.AlterUniqueTogether( + name='realmcount', + unique_together=set([('realm', 'property', 'subgroup', 'end_time', 'interval')]), + ), + migrations.AlterUniqueTogether( + name='streamcount', + unique_together=set([('stream', 'property', 'subgroup', 'end_time', 'interval')]), + ), + migrations.AlterUniqueTogether( + name='usercount', + unique_together=set([('user', 'property', 'subgroup', 'end_time', 'interval')]), + ), + ] diff --git a/analytics/models.py b/analytics/models.py index cc77209e15..7f8df37a45 100644 --- a/analytics/models.py +++ b/analytics/models.py @@ -74,7 +74,7 @@ class BaseCount(ModelReprMixin, models.Model): class InstallationCount(BaseCount): class Meta(object): - unique_together = ("property", "end_time", "interval") + unique_together = ("property", "subgroup", "end_time", "interval") @staticmethod def extended_id(): @@ -94,7 +94,7 @@ class RealmCount(BaseCount): realm = models.ForeignKey(Realm) class Meta(object): - unique_together = ("realm", "property", "end_time", "interval") + unique_together = ("realm", "property", "subgroup", "end_time", "interval") @staticmethod def extended_id(): @@ -115,7 +115,7 @@ class UserCount(BaseCount): realm = models.ForeignKey(Realm) class Meta(object): - unique_together = ("user", "property", "end_time", "interval") + unique_together = ("user", "property", "subgroup", "end_time", "interval") @staticmethod def extended_id(): @@ -136,7 +136,7 @@ class StreamCount(BaseCount): realm = models.ForeignKey(Realm) class Meta(object): - unique_together = ("stream", "property", "end_time", "interval") + unique_together = ("stream", "property", "subgroup", "end_time", "interval") @staticmethod def extended_id():