Add: model index and migrations
This commit is contained in:
parent
a282e9c505
commit
69ac10dec3
@ -0,0 +1,26 @@
|
||||
# Generated by Django 4.1.3 on 2024-11-28 07:10
|
||||
|
||||
import django.contrib.postgres.indexes
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('fwd_api', '0195_alter_subscriptionrequest_request_id_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddIndex(
|
||||
model_name='subscriptionrequestfile',
|
||||
index=django.contrib.postgres.indexes.GinIndex(fields=['predict_result'], name='idx_gin_predict_result'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='subscriptionrequestfile',
|
||||
index=django.contrib.postgres.indexes.GinIndex(fields=['feedback_result'], name='idx_gin_feedback_result'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='subscriptionrequestfile',
|
||||
index=django.contrib.postgres.indexes.GinIndex(fields=['reviewed_result'], name='idx_gin_reviewed_result'),
|
||||
),
|
||||
]
|
@ -0,0 +1,26 @@
|
||||
# Generated by Django 4.1.3 on 2024-11-28 09:04
|
||||
|
||||
import django.contrib.postgres.indexes
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('fwd_api', '0196_subscriptionrequestfile_idx_gin_predict_result_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddIndex(
|
||||
model_name='subscriptionrequest',
|
||||
index=django.contrib.postgres.indexes.GinIndex(fields=['predict_result'], name='idx_gin_rq_predict_result'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='subscriptionrequest',
|
||||
index=django.contrib.postgres.indexes.GinIndex(fields=['feedback_result'], name='idx_gin_rq_feedback_result'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='subscriptionrequest',
|
||||
index=django.contrib.postgres.indexes.GinIndex(fields=['reviewed_result'], name='idx_gin_rq_reviewed_result'),
|
||||
),
|
||||
]
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.1.3 on 2024-11-28 09:40
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('fwd_api', '0197_subscriptionrequest_idx_gin_rq_predict_result_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='subscriptionrequest',
|
||||
name='doc_type',
|
||||
field=models.CharField(db_index=True, max_length=100),
|
||||
),
|
||||
]
|
@ -1,5 +1,6 @@
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.contrib.postgres.indexes import GinIndex
|
||||
|
||||
from fwd_api.models.Subscription import Subscription
|
||||
|
||||
@ -7,7 +8,7 @@ class SubscriptionRequest(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
pages: int = models.IntegerField()
|
||||
pages_left: int = models.IntegerField(default=1)
|
||||
doc_type: str = models.CharField(max_length=100)
|
||||
doc_type: str = models.CharField(max_length=100, db_index=True)
|
||||
request_id = models.CharField(max_length=200, db_index=True) # Change to request_id
|
||||
redemption_id = models.CharField(max_length=200, null=True)
|
||||
process_type = models.CharField(max_length=200) # driver/id/invoice
|
||||
@ -39,3 +40,10 @@ class SubscriptionRequest(models.Model):
|
||||
is_reviewed = models.BooleanField(default=False)
|
||||
is_required = models.BooleanField(default=True)
|
||||
subsidiary = models.CharField(default="", null=True, max_length=200)
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
GinIndex(fields=['predict_result'], name='idx_gin_rq_predict_result'),
|
||||
GinIndex(fields=['feedback_result'], name='idx_gin_rq_feedback_result'),
|
||||
GinIndex(fields=['reviewed_result'], name='idx_gin_rq_reviewed_result'),
|
||||
]
|
@ -1,5 +1,5 @@
|
||||
from django.db import models
|
||||
|
||||
from django.contrib.postgres.indexes import GinIndex
|
||||
from fwd_api.constant.common import FileCategory
|
||||
from fwd_api.models import SubscriptionRequest
|
||||
from fwd_api.models.fields.EncryptedCharField import EncryptedCharField
|
||||
@ -40,5 +40,8 @@ class SubscriptionRequestFile(models.Model):
|
||||
indexes = [
|
||||
models.Index(fields=['request', 'index_in_request', 'doc_type']), # For updating results
|
||||
models.Index(fields=['request', 'file_name']), # for getting image files by AI
|
||||
GinIndex(fields=['predict_result'], name='idx_gin_predict_result'),
|
||||
GinIndex(fields=['feedback_result'], name='idx_gin_feedback_result'),
|
||||
GinIndex(fields=['reviewed_result'], name='idx_gin_reviewed_result'),
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user