fix(mcp_store): add db_default to MCPServerTemplate category column - #70416
Conversation
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
|
Hey @cvolzer3! 👋 It looks like your git author email on this PR isn't your
You can fix it for this repo with: git config user.email "you@posthog.com"Or set it globally with |
Migration SQL ChangesHey 👋, we've detected some migrations on this PR. Here's the SQL output for each migration, make sure they make sense:
|
🔍 Migration Risk AnalysisWe've analyzed your migrations for potential risks. Summary: 0 Safe | 1 Needs Review | 0 Blocked
|
|
Reviews (1): Last reviewed commit: "fix(mcp_store): add db_default to MCPSer..." | Re-trigger Greptile |
Problem
The
MCPServerTemplate.categorycolumn was addedNOT NULLwith a Python-onlydefault="dev"and no Postgres-level default. Django'sdefault=is applied atModel.__init__, so it is invisible to any path that doesn't go through the ORM: rawINSERTs, and the model-driven test schema build insetup_test_environment.py(which callsdisable_migrations()and skips migrations entirely). Those paths hit aNotNullViolationoncategory.Changes
Add
db_default="dev"to thecategoryfield so Postgres carries a real columnDEFAULT. New migration0013emits a singleALTER COLUMN ... SET DEFAULT 'dev'with noDROP DEFAULTfollow-up. This matches the siblingscopecolumn added in0012, which already usesdb_default.How did you test this code?
I (the PostHog Slack app agent) could not run
makemigrationsor the test suite in this environment (no Django installed), so I hand-wrote migration0013to match exactly whatmakemigrationsemits whendb_defaultis added to the field's model state, and updatedmax_migration.txt. Please let CI run the migration and parity checks.Automatic notifications
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Raised from a Slack thread as a P2 inbox item. Invoked the
/django-migrationsskill, which flags exactly this cross-languageNOT NULLhazard: a scalar Djangodefault=does not create a Postgres column default, so non-ORM writers and the model-driven test schema build break. Followed its guidance to add bothdefault=anddb_default=. I chose anAlterFieldmigration over a rawRunSQLso the migration reflects the model state andmakemigrationsreports no drift.