-- =============================================================
-- V018: Add platform columns to reschedule_proposals
-- =============================================================
-- Add platform columns to reschedule_proposals to support Discord reschedule voting.
-- proposed_by is made nullable so Discord proposals can leave it NULL
-- (Discord snowflakes don't fit in BIGINT safely).
-- =============================================================

ALTER TABLE reschedule_proposals
    ALTER COLUMN proposed_by DROP NOT NULL;

ALTER TABLE reschedule_proposals
    ADD COLUMN source_platform VARCHAR(50),
    ADD COLUMN proposed_by_external_user_id VARCHAR(255);

UPDATE reschedule_proposals
SET source_platform = 'Telegram',
    proposed_by_external_user_id = proposed_by::TEXT
WHERE source_platform IS NULL;
