Skip to content

Commit

Permalink
fix(analytics): move feature_name index into its own migration file (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewelwell authored Feb 16, 2024
1 parent d63a289 commit 39b7300
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@


class Migration(migrations.Migration):

atomic = False
"""
This migration class used to include the addition of the index that now lives
in 0003_add_feature_name_index. The reason for this can be attributed to the
discussion here: https://github.com/Flagsmith/flagsmith/issues/3425
"""

dependencies = [
('app_analytics', '0001_initial'),
Expand All @@ -23,19 +26,4 @@ class Migration(migrations.Migration):
name='enabled_when_evaluated',
field=models.BooleanField(null=True, default=None),
),
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterField(
model_name='featureevaluationraw',
name='feature_name',
field=models.CharField(db_index=True, max_length=2000),
),
],
database_operations=[
PostgresOnlyRunSQL(
'CREATE INDEX CONCURRENTLY "app_analytics_featureevaluationraw_feature_name_idx" ON "app_analytics_featureevaluationraw" ("feature_name");',
reverse_sql='DROP INDEX CONCURRENTLY "app_analytics_featureevaluationraw_feature_name_idx";',
)
],
),
]
32 changes: 32 additions & 0 deletions api/app_analytics/migrations/0003_add_feature_name_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 3.2.23 on 2024-02-15 18:33

from django.db import migrations, models

from core.migration_helpers import PostgresOnlyRunSQL


class Migration(migrations.Migration):

atomic = False

dependencies = [
("app_analytics", "0002_featureevaluationraw_identifier_and_index_feature"),
]

operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.AlterField(
model_name="featureevaluationraw",
name="feature_name",
field=models.CharField(db_index=True, max_length=2000),
),
],
database_operations=[
PostgresOnlyRunSQL(
'CREATE INDEX CONCURRENTLY IF NOT EXISTS "app_analytics_featureevaluationraw_feature_name_idx" ON "app_analytics_featureevaluationraw" ("feature_name");',
reverse_sql='DROP INDEX CONCURRENTLY IF EXISTS "app_analytics_featureevaluationraw_feature_name_idx";',
)
],
),
]

0 comments on commit 39b7300

Please sign in to comment.