Skip to content

Commit

Permalink
Merge pull request #4299 from unicef/index-document-number
Browse files Browse the repository at this point in the history
[217253] Migrate Document Number Field with Async Indexing
  • Loading branch information
pkujawa authored Oct 8, 2024
2 parents 4ad6379 + c6f075a commit 36f5811
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions src/hct_mis_api/apps/household/migrations/0186_migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 3.2.25 on 2024-10-07 14:09
from django.contrib.postgres.operations import AddIndexConcurrently
from django.db import migrations, models


class Migration(migrations.Migration):
atomic = False

dependencies = [
('household', '0185_migration'),
]

operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterField(
model_name='document',
name='document_number',
field=models.CharField(db_index=True),
),
],
database_operations=[
AddIndexConcurrently(
model_name="document",
index=models.Index(
fields=["document_number"], name="household_document_number_idx"
)
),
]
)
]
2 changes: 1 addition & 1 deletion src/hct_mis_api/apps/household/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ class Document(AbstractSyncable, SoftDeletableRepresentationMergeStatusModel, Ti
(STATUS_INVALID, _("Invalid")),
)

document_number = models.CharField(max_length=255, blank=True)
document_number = models.CharField(max_length=255, blank=True, db_index=True)
photo = models.ImageField(blank=True)
individual = models.ForeignKey("Individual", related_name="documents", on_delete=models.CASCADE)
type = models.ForeignKey("DocumentType", related_name="documents", on_delete=models.CASCADE)
Expand Down

0 comments on commit 36f5811

Please sign in to comment.