:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(dashboards): add missing index on dashboardtile.button_tile_id (#68726)
Fernando Gomes2e77aee19c72
diff --git a/products/dashboards/backend/migrations/0013_dashboardtile_button_tile_id_idx.py b/products/dashboards/backend/migrations/0013_dashboardtile_button_tile_id_idx.pynew file mode 100644index 000000000000..121f8ff8def1--- /dev/null+++ b/products/dashboards/backend/migrations/0013_dashboardtile_button_tile_id_idx.py@@ -0,0 +1,37 @@+import django.db.models.deletion+from django.db import migrations, models++from posthog.migration_helpers import CreateIndexConcurrently+++class Migration(migrations.Migration):+ # Concurrent index builds cannot run inside a transaction.+ atomic = False++ dependencies = [+ ("dashboards", "0012_alter_dashboardtemplate_scope"),+ ]++ operations = [+ migrations.SeparateDatabaseAndState(+ state_operations=[+ migrations.AlterField(+ model_name="dashboardtile",+ name="button_tile",+ field=models.ForeignKey(+ db_index=False,+ null=True,+ on_delete=django.db.models.deletion.CASCADE,+ related_name="dashboard_tiles",+ to="dashboards.buttontile",+ ),+ ),+ ],+ ),+ CreateIndexConcurrently(+ index_name="posthog_dashboardtile_button_tile_id_idx",+ table_name="posthog_dashboardtile",+ columns='("button_tile_id")',+ where='WHERE "button_tile_id" IS NOT NULL',+ ),+ ]diff --git a/products/dashboards/backend/migrations/max_migration.txt b/products/dashboards/backend/migrations/max_migration.txtindex 4f4c0cdd9857..7be944e51545 100644--- a/products/dashboards/backend/migrations/max_migration.txt+++ b/products/dashboards/backend/migrations/max_migration.txt@@ -1 +1 @@-0012_alter_dashboardtemplate_scope+0013_dashboardtile_button_tile_id_idxdiff --git a/products/dashboards/backend/models/dashboard_tile.py b/products/dashboards/backend/models/dashboard_tile.pyindex 75e10b161c42..3e2abc4b6896 100644--- a/products/dashboards/backend/models/dashboard_tile.py+++ b/products/dashboards/backend/models/dashboard_tile.py@@ -76,6 +76,7 @@ class DashboardTile(models.Model):on_delete=models.CASCADE,related_name="dashboard_tiles",null=True,+ db_index=False,)widget = models.ForeignKey("dashboards.DashboardWidget",