-- Migration 004: Add global_master_tracking_id column to master_assets
-- Purpose: Links local campaign assets (A1→A2) back to their global master (B1→B2)
--          by storing the M-prefixed tracking ID from the B1 record
-- Date: 2026-03-21

ALTER TABLE master_assets
ADD COLUMN IF NOT EXISTS global_master_tracking_id VARCHAR(6);

-- Index for lookups
CREATE INDEX IF NOT EXISTS idx_master_assets_global_master_tracking
ON master_assets(global_master_tracking_id);

\echo 'Migration 004 complete: Added global_master_tracking_id to master_assets'
