Skip to content

fix(mcp_store): add db_default to MCPServerTemplate category column - #70416

Merged
cvolzer3 merged 1 commit into
masterfrom
posthog-code/mcp-store-category-db-default
Jul 13, 2026
Merged

fix(mcp_store): add db_default to MCPServerTemplate category column#70416
cvolzer3 merged 1 commit into
masterfrom
posthog-code/mcp-store-category-db-default

Conversation

@cvolzer3

Copy link
Copy Markdown
Contributor

Problem

The MCPServerTemplate.category column was added NOT NULL with a Python-only default="dev" and no Postgres-level default. Django's default= is applied at Model.__init__, so it is invisible to any path that doesn't go through the ORM: raw INSERTs, and the model-driven test schema build in setup_test_environment.py (which calls disable_migrations() and skips migrations entirely). Those paths hit a NotNullViolation on category.

Changes

Add db_default="dev" to the category field so Postgres carries a real column DEFAULT. New migration 0013 emits a single ALTER COLUMN ... SET DEFAULT 'dev' with no DROP DEFAULT follow-up. This matches the sibling scope column added in 0012, which already uses db_default.

How did you test this code?

I (the PostHog Slack app agent) could not run makemigrations or the test suite in this environment (no Django installed), so I hand-wrote migration 0013 to match exactly what makemigrations emits when db_default is added to the field's model state, and updated max_migration.txt. Please let CI run the migration and parity checks.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Raised from a Slack thread as a P2 inbox item. Invoked the /django-migrations skill, which flags exactly this cross-language NOT NULL hazard: a scalar Django default= does not create a Postgres column default, so non-ORM writers and the model-driven test schema build break. Followed its guidance to add both default= and db_default=. I chose an AlterField migration over a raw RunSQL so the migration reflects the model state and makemigrations reports no drift.

The category column was added NOT NULL with a Python-only default,
which is invisible to non-Django schema paths (raw inserts and the
model-driven test schema build). Add db_default="dev" so Postgres
carries a real column default, matching the sibling scope column.

Generated-By: PostHog Code
Task-Id: 29ccad5b-b5be-4a62-b68d-4baf89a408a5
@cvolzer3 cvolzer3 self-assigned this Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hey @cvolzer3! 👋

It looks like your git author email on this PR isn't your @posthog.com address (cvolzer3@gmail.com). Since you're on the PostHog team, it's worth pointing your local git author email at your @posthog.com address. Why it matters:

  • Consistent work identity in git history — internal tooling that attributes commits to team members keys off your @posthog.com address.
  • Keeps team contributions easy to tell apart from external community ones when scanning history.

You can fix it for this repo with:

git config user.email "you@posthog.com"

Or set it globally with git config --global user.email "you@posthog.com". No need to redo this PR — just a nudge for next time. 🙂

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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/mcp_store/backend/migrations/0013_alter_mcpservertemplate_category_db_default.py

BEGIN;
--
-- Alter field category on mcpservertemplate
--
ALTER TABLE "mcp_store_mcpservertemplate" ALTER COLUMN "category" SET DEFAULT 'dev';
COMMIT;

Last updated: 2026-07-13 17:53 UTC (dcf9eb0)

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

🔍 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

mcp_store.0013_alter_mcpservertemplate_category_db_default
  └─ #1 ⚠️ AlterField
     Field alteration may cause table locks or data loss (check if changing type or constraints)
     model: mcpservertemplate, field: category, field_type: CharField

Last updated: 2026-07-13 17:53 UTC (dcf9eb0)

@trunk-io

trunk-io Bot commented Jul 13, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@cvolzer3
cvolzer3 requested a review from a team July 13, 2026 13:25
@cvolzer3
cvolzer3 marked this pull request as ready for review July 13, 2026 13:25
@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(mcp_store): add db_default to MCPSer..." | Re-trigger Greptile

@cvolzer3
cvolzer3 merged commit b24daf2 into master Jul 13, 2026
381 of 392 checks passed
@cvolzer3
cvolzer3 deleted the posthog-code/mcp-store-category-db-default branch July 13, 2026 18:13
@deployment-status-posthog

deployment-status-posthog Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-13 18:41 UTC Run
prod-us ✅ Deployed 2026-07-13 18:55 UTC Run
prod-eu ✅ Deployed 2026-07-13 19:02 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