-- Phase 2: provenance columns (E-anchored capital, PnL source)
-- Apply BEFORE deploying code that emits these fields.
-- ALTER TABLE ... ADD COLUMN IF NOT EXISTS is idempotent.

ALTER TABLE dolphin_pink.account_events
    ADD COLUMN IF NOT EXISTS `capital_source` LowCardinality(String) DEFAULT '',
    ADD COLUMN IF NOT EXISTS `account_event_seq` UInt64 DEFAULT 0;

ALTER TABLE dolphin_pink.status_snapshots
    ADD COLUMN IF NOT EXISTS `capital_source` LowCardinality(String) DEFAULT '',
    ADD COLUMN IF NOT EXISTS `account_event_seq` UInt64 DEFAULT 0;

ALTER TABLE dolphin_pink.trade_events
    ADD COLUMN IF NOT EXISTS `pnl_source` LowCardinality(String) DEFAULT '';

ALTER TABLE dolphin_pink.trade_exit_legs
    ADD COLUMN IF NOT EXISTS `pnl_source` LowCardinality(String) DEFAULT '';
