Skip to content

Commit

Permalink
fix(models/featureevaluationraw): Add index on crated_at (#4405)
Browse files Browse the repository at this point in the history
  • Loading branch information
gagantrivedi authored Jul 30, 2024
1 parent ba8cd56 commit 1f90900
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.2.25 on 2024-07-29 10:01

from django.db import migrations, models

from core.migration_helpers import PostgresOnlyRunSQL


class Migration(migrations.Migration):

atomic = False
dependencies = [
("app_analytics", "0004_apiusageraw_count"),
]

operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AddIndex(
model_name="featureevaluationraw",
index=models.Index(
fields=["created_at"],
name="f_evaluation_created_at_idx",
),
)
],
database_operations=[
PostgresOnlyRunSQL(
'CREATE INDEX CONCURRENTLY IF NOT EXISTS "f_evaluation_created_at_idx" ON "app_analytics_featureevaluationraw" ("created_at");',
reverse_sql='DROP INDEX CONCURRENTLY IF EXISTS "f_evaluation_created_at_idx"',
)
],
)
]
8 changes: 8 additions & 0 deletions api/app_analytics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ class FeatureEvaluationRaw(models.Model):
identity_identifier = models.CharField(max_length=2000, null=True, default=None)
enabled_when_evaluated = models.BooleanField(null=True, default=None)

class Meta:
indexes = [
models.Index(
fields=["created_at"],
name="f_evaluation_created_at_idx",
),
]


class FeatureEvaluationBucket(AbstractBucket):
feature_name = models.CharField(max_length=2000)
Expand Down

0 comments on commit 1f90900

Please sign in to comment.