Skip to content

Commit 4ecaf44

Browse files
committed
fix: handle NULL status values in migration 008
Fixes production deployment crash where migration 008 fails with: "column status of relation servers contains null values" Problem: - Migration was extracting status from wrong location - Old format has status at TOP LEVEL of JSON, not in official metadata - 9 servers have explicit "status": null in their JSON - Migration incorrectly tried to extract from official_meta->>'status' (always NULL) - This would cause ALL servers to have NULL status, failing NOT NULL constraint Solution: - Extract status from TOP LEVEL JSON (rec.value->>'status') for all records - Use NULLIF to convert string 'null' to SQL NULL, then COALESCE to 'active' - Ensures all status values are non-NULL before constraint is added Affected servers with null status: - com.biodnd/agent-ip - io.github.jkakar/cookwith-mcp - com.joelverhagen.mcp/Knapcode.SampleMcpServer - io.github.Lyellr88/marm-mcp-server - com.biodnd/agent-press - io.github.timheuer/sampledotnetmcpserver - io.github.CodeCraftersLLC/local-voice-mcp - com.biodnd/agent-fin - io.github.ruvnet/ruv-swarm
1 parent a0bc09d commit 4ecaf44

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

internal/database/migrations/008_separate_official_metadata.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ BEGIN
3535

3636
IF official_meta IS NOT NULL THEN
3737
-- Update columns with extracted metadata
38+
-- Note: status is at top level in old format, not in official_meta
3839
UPDATE servers
3940
SET
40-
status = (official_meta->>'status')::VARCHAR(50),
41+
status = COALESCE(NULLIF(rec.value->>'status', 'null'), 'active'),
4142
published_at = (official_meta->>'publishedAt')::TIMESTAMP WITH TIME ZONE,
4243
updated_at = (official_meta->>'updatedAt')::TIMESTAMP WITH TIME ZONE,
4344
is_latest = (official_meta->>'isLatest')::BOOLEAN
@@ -46,7 +47,7 @@ BEGIN
4647
-- Handle records without official metadata (set defaults)
4748
UPDATE servers
4849
SET
49-
status = COALESCE((rec.value->>'status'), 'active'),
50+
status = COALESCE(NULLIF(rec.value->>'status', 'null'), 'active'),
5051
published_at = NOW(),
5152
updated_at = NOW(),
5253
is_latest = true

0 commit comments

Comments
 (0)