Skip to content

Commit

Permalink
Merge pull request #2564 from onaio/add-instance-history-indexing
Browse files Browse the repository at this point in the history
Add Instance History indexing to checksum & uuid fields
  • Loading branch information
KipSigei authored Mar 7, 2024
2 parents 02e8e92 + 96214c7 commit 7c60107
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 3.2.23 on 2024-03-07 06:57

from django.db import migrations, models


class Migration(migrations.Migration):
atomic = False

dependencies = [
('logger', '0011_add_xform_id_instance_id_idx'),
]

operations = [
migrations.SeparateDatabaseAndState(
database_operations=[
migrations.RunSQL(
sql='CREATE INDEX CONCURRENTLY "logger_inst_hist_checksum_05f7bf_idx" ON "logger_instancehistory" ("checksum");',
reverse_sql='DROP INDEX "logger_inst_hist_checksum_05f7bf_idx";',
),
migrations.RunSQL(
sql='CREATE INDEX CONCURRENTLY "logger_inst_hist_uuid_f5ae42_idx" ON "logger_instancehistory" ("uuid");',
reverse_sql='DROP INDEX "logger_inst_hist_uuid_f5ae42_idx";',
),
],
state_operations=[
migrations.AddIndex(
model_name='instancehistory',
index=models.Index(
fields=['checksum'], name='logger_inst_hist_checksum_05f7bf_idx'
),
),
migrations.AddIndex(
model_name='instancehistory',
index=models.Index(
fields=['uuid'], name='logger_inst_hist_uuid_f5ae42_idx'
),
),
],
)
]
4 changes: 2 additions & 2 deletions onadata/apps/logger/models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,13 +901,13 @@ class Meta:

xml = models.TextField()
# old instance id
uuid = models.CharField(max_length=249, default="")
uuid = models.CharField(max_length=249, default="", db_index=True)

date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
submission_date = models.DateTimeField(null=True, default=None)
geom = models.GeometryCollectionField(null=True)
checksum = models.CharField(max_length=64, null=True, blank=True)
checksum = models.CharField(max_length=64, null=True, blank=True, db_index=True)

@property
def xform(self):
Expand Down

0 comments on commit 7c60107

Please sign in to comment.