Skip to content

fix(#34): rename campaign_snapshots.campaign_p_id to campaign_pid#35

Merged
Jing-yilin merged 1 commit intodevelopfrom
fix/34-snapshot-column-name
Feb 27, 2026
Merged

fix(#34): rename campaign_snapshots.campaign_p_id to campaign_pid#35
Jing-yilin merged 1 commit intodevelopfrom
fix/34-snapshot-column-name

Conversation

@Jing-yilin
Copy link
Contributor

Problem

The campaign_snapshots table had a column name mismatch causing 5,614 snapshot insert failures on each crawl:

ERROR: column "campaign_pid" does not exist (SQLSTATE 42703)

Root cause: CampaignSnapshot.CampaignPID field was missing gorm:"column:campaign_pid" tag, causing GORM to snake_case it as campaign_p_id (same issue as #24 for campaigns table).

Solution

  1. ✅ Added column:campaign_pid to GORM tag in model
  2. ✅ Added idempotent migration to rename existing column

Impact

Before:

  • ❌ 5,614 snapshot inserts fail every crawl
  • ❌ No historical data for sparkline charts
  • ❌ Velocity calculations broken

After:

  • ✅ Snapshots will be stored correctly
  • ✅ Sparkline charts will have data
  • ✅ Velocity tracking will work

Testing

  • ✅ Go build succeeds
  • ✅ Tests pass
  • Migration will run automatically on next deployment

Related

🤖 Generated with Claude Code

The CampaignSnapshot model field `CampaignPID` was missing the
`gorm:"column:campaign_pid"` tag, causing GORM to snake_case it as
`campaign_p_id` instead of the expected `campaign_pid`.

This caused all snapshot inserts to fail with:
  ERROR: column "campaign_pid" does not exist (SQLSTATE 42703)

Changes:
1. Added `column:campaign_pid` GORM tag to model
2. Added idempotent migration to rename existing column

Same root cause as campaigns.pid issue (#24).

Fixes #34

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@Jing-yilin Jing-yilin merged commit a8e9fd0 into develop Feb 27, 2026
2 checks passed
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.

1 participant