Skip to content

feat(dashboards): add DashboardWidget model and table migration (1/11)#60489

Merged
MattPua merged 2 commits into
masterfrom
05-28-chore_dashboards_add_dashboardwidget_model_and_table_migration
May 29, 2026
Merged

feat(dashboards): add DashboardWidget model and table migration (1/11)#60489
MattPua merged 2 commits into
masterfrom
05-28-chore_dashboards_add_dashboardwidget_model_and_table_migration

Conversation

@MattPua
Copy link
Copy Markdown
Member

@MattPua MattPua commented May 28, 2026

Problem

Dashboard widgets need a first-class persisted entity (DashboardWidget) separate from insights and text tiles. This stack starts with schema-only changes so each migration can ship and deploy independently.

This PR is 1/10 in the dashboard widgets Graphite stack (migration foundation).

Changes

  • Add DashboardWidget model (products/dashboards/backend/models/dashboard_widget.py)
  • Migration 0007_dashboardwidget_table — creates posthog_dashboardwidget (new table only, no locks on existing dashboard tables)
  • Wire model into products/dashboards/backend/models/__init__.py

How did you test this code?

  • Agent: did not run manual migrations locally
  • hogli test products/dashboards/backend/ — not run on this slice alone; migration is additive-only

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Publish to changelog?

no

Docs update

skip-inkeep-docs (internal schema prep)

🤖 Agent context

  • Agent-assisted split of the dashboard-widget-foundation WIP branch into a 10-PR Graphite stack for safer review and deploy
  • Lock-risk migrations are isolated into separate PRs (this one is low risk: new table only)
  • No product behavior change until later stack PRs

@MattPua MattPua force-pushed the 05-28-chore_dashboards_add_dashboardwidget_model_and_table_migration branch from 4206a12 to 416a5ab Compare May 28, 2026 17:22
@MattPua MattPua marked this pull request as ready for review May 28, 2026 17:37
@MattPua MattPua changed the title chore(dashboards): add DashboardWidget model and table migration feat(dashboards): add DashboardWidget model and table migration May 28, 2026
@assign-reviewers-posthog assign-reviewers-posthog Bot requested review from a team May 28, 2026 17:38
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 28, 2026

Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 28, 2026

Migration SQL Changes

Hey 👋, we've detected some migrations on this PR. Here's the SQL output for each migration, make sure they make sense:

products/dashboards/backend/migrations/0007_dashboardwidget_table.py

BEGIN;
--
-- Custom state/database change combination
--

                        CREATE TABLE "posthog_dashboardwidget" (
                            "id" uuid NOT NULL PRIMARY KEY,
                            "widget_type" varchar(64) NOT NULL,
                            "name" varchar(400) NULL,
                            "description" text NOT NULL,
                            "config" jsonb NOT NULL,
                            "last_modified_at" timestamp with time zone NOT NULL,
                            "created_by_id" integer NULL REFERENCES "posthog_user" ("id") DEFERRABLE INITIALLY DEFERRED,
                            "last_modified_by_id" integer NULL REFERENCES "posthog_user" ("id") DEFERRABLE INITIALLY DEFERRED,
                            "team_id" integer NOT NULL REFERENCES "posthog_team" ("id") DEFERRABLE INITIALLY DEFERRED
                        );
                        CREATE INDEX IF NOT EXISTS "posthog_dashboardwidget_created_by_id" ON "posthog_dashboardwidget" ("created_by_id");
                        CREATE INDEX IF NOT EXISTS "posthog_dashboardwidget_last_modified_by_id" ON "posthog_dashboardwidget" ("last_modified_by_id");
                        CREATE INDEX IF NOT EXISTS "posthog_dashboardwidget_team_id" ON "posthog_dashboardwidget" ("team_id");
                    
COMMIT;

Last updated: 2026-05-28 19:01 UTC (d76dea8)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 28, 2026

🔍 Migration Risk Analysis

We've analyzed your migrations for potential risks.

Summary: 0 Safe | 1 Needs Review | 0 Blocked

⚠️ Needs Review

May have performance impact

dashboards.0007_dashboardwidget_table
  └─ #1 ✅ SeparateDatabaseAndState
     Wrapper operation - see nested operations for risk: RunSQL
     database_operations: RunSQL
     └─ #2 ⚠️ RunSQL: CREATE INDEX without CONCURRENTLY locks table

📚 How to Deploy These Changes Safely

RunSQL:

Use CONCURRENTLY to avoid table locks: CREATE INDEX CONCURRENTLY IF NOT EXISTS

Last updated: 2026-05-28 19:02 UTC (d76dea8)

@MattPua MattPua requested a review from vdekrijger May 28, 2026 17:48
@MattPua MattPua changed the title feat(dashboards): add DashboardWidget model and table migration feat(dashboards): add DashboardWidget model and table migration (1/10) May 28, 2026
…tate

makemigrations --check failed because CreateModel omitted the
default_manager_name and all_teams manager from DashboardWidget's
TeamScopedRootMixin setup.

Co-authored-by: Cursor <cursoragent@cursor.com>
@MattPua MattPua removed the request for review from a team May 28, 2026 19:41
@MattPua MattPua changed the title feat(dashboards): add DashboardWidget model and table migration (1/10) feat(dashboards): add DashboardWidget model and table migration (1/12) May 28, 2026
@MattPua MattPua changed the title feat(dashboards): add DashboardWidget model and table migration (1/12) feat(dashboards): add DashboardWidget model and table migration (1/11) May 28, 2026
@MattPua MattPua merged commit 5d7ebb0 into master May 29, 2026
231 of 233 checks passed
@MattPua MattPua deleted the 05-28-chore_dashboards_add_dashboardwidget_model_and_table_migration branch May 29, 2026 13:28
@deployment-status-posthog
Copy link
Copy Markdown

deployment-status-posthog Bot commented May 29, 2026

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-05-29 13:55 UTC Run
prod-us ✅ Deployed 2026-05-29 14:26 UTC Run
prod-eu ✅ Deployed 2026-05-29 14:37 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants