Skip to content

Commit

Permalink
Replace the use of index_together
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Aug 21, 2024
1 parent 6120f55 commit 4a43914
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.8 on 2024-08-21 12:10

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("contacts", "0027_install_triggers"),
]

operations = [
migrations.RenameIndex(
model_name="reporterscounter",
new_name="contacts_re_org_id_d53a00_idx",
old_fields=("org", "type"),
),
]
2 changes: 1 addition & 1 deletion ureport/contacts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def get_counts(cls, org, types=None):
return {c["type"]: c["count_sum"] for c in counter_counts}

class Meta:
index_together = ("org", "type")
indexes = [
models.Index(name="contacts_rptrscntr_org_typ_cnt", fields=["org", "type", "count"]),
models.Index(name=None, fields=["org", "type"]),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.8 on 2024-08-21 12:10

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("landingpages", "0004_alter_landingpage_created_by_and_more"),
]

operations = [
migrations.RenameIndex(
model_name="landingpage",
new_name="landingpage_org_id_80f356_idx",
old_fields=("org", "slug"),
),
]
4 changes: 3 additions & 1 deletion ureport/landingpages/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class LandingPage(SmartModel):
bots = models.ManyToManyField(Bot, blank=True)

class Meta:
index_together = (("org", "slug"),)
indexes = [
models.Index(name=None, fields=["org", "slug"]),
]
constraints = [
models.UniqueConstraint(fields=["org", "slug"], name="landingpages_landingpage_org_id_slug_f7f1304e_uniq")
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.8 on 2024-08-21 12:10

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("locations", "0007_alter_boundary_index_together"),
]

operations = [
migrations.RenameIndex(
model_name="boundary",
new_name="locations_b_org_id_ee9365_idx",
old_fields=("org", "level", "name", "osm_id"),
),
]
4 changes: 3 additions & 1 deletion ureport/locations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ class Meta:
constraints = [
models.UniqueConstraint(fields=["org", "osm_id"], name="locations_boundary_org_id_5c2d99160b82334a_uniq")
]
index_together = ("org", "level", "name", "osm_id")
indexes = [
models.Index(name=None, fields=["org", "level", "name", "osm_id"]),
]

@classmethod
def lock(cls, org, osm_id):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 5.0.8 on 2024-08-21 12:15

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("polls", "0076_alter_poll_index_together"),
]

operations = [
migrations.RenameIndex(
model_name="poll",
new_name="polls_poll_org_id_3461d6_idx",
old_fields=("org", "published", "id"),
),
migrations.RenameIndex(
model_name="pollquestion",
new_name="polls_pollq_poll_id_68485b_idx",
old_fields=("poll", "is_active", "flow_result"),
),
migrations.RenameIndex(
model_name="pollresult",
new_name="polls_pollr_org_id_428d8a_idx",
old_fields=("org", "flow", "ruleset", "text"),
),
migrations.RenameIndex(
model_name="pollresult",
new_name="polls_pollr_org_id_0f793f_idx",
old_fields=("org", "flow"),
),
]
13 changes: 10 additions & 3 deletions ureport/polls/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,9 @@ def __str__(self):
return self.title

class Meta:
index_together = ("org", "published", "id")
indexes = [
models.Index(name=None, fields=["org", "published", "id"]),
]


@six.python_2_unicode_compatible
Expand Down Expand Up @@ -1302,7 +1304,9 @@ class Meta:
fields=["poll", "flow_result"], name="polls_pollquestion_poll_id_flow_result_id_608a2446_uniq"
),
]
index_together = ("poll", "is_active", "flow_result")
indexes = [
models.Index(name=None, fields=["poll", "is_active", "flow_result"]),
]


class PollResponseCategory(models.Model):
Expand Down Expand Up @@ -1451,4 +1455,7 @@ def generate_poll_stats(self):
return generated_stats

class Meta:
index_together = [["org", "flow"], ["org", "flow", "ruleset", "text"]]
indexes = [
models.Index(name=None, fields=["org", "flow"]),
models.Index(name=None, fields=["org", "flow", "ruleset", "text"]),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.0.8 on 2024-08-21 12:10

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("stats", "0028_activities_counter_triggers"),
]

operations = [
migrations.RenameIndex(
model_name="contactactivity",
new_name="stats_conta_org_id_296d47_idx",
old_fields=("org", "date"),
),
migrations.RenameIndex(
model_name="contactactivity",
new_name="stats_conta_org_id_e76e89_idx",
old_fields=("org", "contact"),
),
]
5 changes: 4 additions & 1 deletion ureport/stats/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,10 @@ class ContactActivity(models.Model):
used = models.BooleanField(null=True)

class Meta:
index_together = (("org", "contact"), ("org", "date"))
indexes = [
models.Index(name=None, fields=["org", "contact"]),
models.Index(name=None, fields=["org", "date"]),
]
constraints = [
models.UniqueConstraint(
fields=["org", "contact", "date"], name="stats_contactactivity_org_id_contact_date_348227aa_uniq"
Expand Down

0 comments on commit 4a43914

Please sign in to comment.