Skip to content

fix: campaign_snapshots column name mismatch - campaign_p_id vs campaign_pid #34

@Jing-yilin

Description

@Jing-yilin

Problem

The campaign_snapshots table has a column name mismatch causing snapshot storage to fail:

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

Root cause:

  • Model field: CampaignPID string
  • GORM snake_case: campaign_p_id (incorrect due to PIDp_id)
  • Expected: campaign_pid

This is the same issue we had with the campaigns table PK (#24), but we forgot to fix it for the foreign key in campaign_snapshots.

Impact

  • ❌ All snapshot inserts fail (5,614 errors on each crawl)
  • ❌ Sparkline charts have no historical data
  • ❌ Velocity calculations broken

Current State

From logs (2026-02-27 14:12 UTC):

  • ✅ 5,614 campaigns upserted successfully
  • ❌ 5,614 snapshot inserts failed with campaign_pid error

Solution

Add idempotent migration in db.go:

  1. Rename campaign_p_idcampaign_pid if exists
  2. Update GORM tag: gorm:"column:campaign_pid"

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendBackend relatedbugSomething isn't workingpriority:highHigh priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions