index for jsonfield
This commit is contained in:
parent
1c42e3784a
commit
89768fa02e
2 changed files with 81 additions and 0 deletions
|
|
@ -0,0 +1,37 @@
|
|||
# Generated by Django 5.1.7 on 2025-11-15 11:19
|
||||
|
||||
import django.contrib.postgres.indexes
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('promotions', '0005_alter_event_user'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
migrations.swappable_dependency(settings.OAUTH2_PROVIDER_APPLICATION_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddIndex(
|
||||
model_name='event',
|
||||
index=django.contrib.postgres.indexes.GinIndex(fields=['data'], name='promotions_event_data_bc656abc'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='plan',
|
||||
index=django.contrib.postgres.indexes.GinIndex(fields=['event_list'], name='promotions_plan_event_783bb033'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='plan',
|
||||
index=django.contrib.postgres.indexes.GinIndex(fields=['data'], name='promotions_plan_data_b632bc41'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='promotion',
|
||||
index=django.contrib.postgres.indexes.GinIndex(fields=['data'], name='promotions_promotion_cb76da3e'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='recipient',
|
||||
index=django.contrib.postgres.indexes.GinIndex(fields=['data'], name='promotions_recipient_fba22446'),
|
||||
),
|
||||
]
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import uuid
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.postgres.indexes import GinIndex
|
||||
from django.db import models, transaction
|
||||
from django.db.models import F
|
||||
from django.utils import timezone
|
||||
|
|
@ -67,6 +68,15 @@ class Event(BaseModel):
|
|||
|
||||
objects = EventQuerySet.as_manager()
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
GinIndex(
|
||||
fields=['data'],
|
||||
# hashlib.md5("promotions_event_data_GinIndex".encode()).hexdigest()[:8] used for hash
|
||||
name='promotions_event_data_bc656abc'
|
||||
),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.label
|
||||
|
||||
|
|
@ -101,6 +111,20 @@ class Plan(BaseModel):
|
|||
|
||||
objects = PlanQuerySet.as_manager()
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
GinIndex(
|
||||
fields=['event_list'],
|
||||
# hashlib.md5("promotions_plan_event_list_GinIndex".encode()).hexdigest()[:8] used for hash
|
||||
name='promotions_plan_event_783bb033'
|
||||
),
|
||||
GinIndex(
|
||||
fields=['data'],
|
||||
# hashlib.md5("promotions_plan_data_GinIndex".encode()).hexdigest()[:8] used for hash
|
||||
name='promotions_plan_data_b632bc41'
|
||||
),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
|
|
@ -133,6 +157,16 @@ class Recipient(BaseModel):
|
|||
|
||||
data = models.JSONField(null=True, blank=True, default=dict)
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
GinIndex(
|
||||
fields=['data'],
|
||||
# hashlib.md5("promotions_recipient_data_GinIndex".encode()).hexdigest()[:8] used for hash
|
||||
name='promotions_recipient_fba22446'
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.label} --> {self.plan}"
|
||||
|
||||
|
|
@ -259,6 +293,16 @@ class Promotion(BaseModel):
|
|||
|
||||
objects = PromotionQuerySet.as_manager()
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
GinIndex(
|
||||
fields=['data'],
|
||||
# hashlib.md5("promotions_promotion_data_GinIndex".encode()).hexdigest()[:8] used for hash
|
||||
name='promotions_promotion_cb76da3e'
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def change_state(self, from_states: list | tuple, to_state, same_ok=True, raise_exception=False,
|
||||
error_message=None,
|
||||
data: None | dict = None):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue