-- Add relationship fields to polls table
ALTER TABLE polls ADD COLUMN IF NOT EXISTS related_article_id INTEGER REFERENCES articles(id) ON DELETE SET NULL;
ALTER TABLE polls ADD COLUMN IF NOT EXISTS related_event_id INTEGER REFERENCES events(id) ON DELETE SET NULL;
ALTER TABLE polls ADD COLUMN IF NOT EXISTS related_video_url VARCHAR(500);

-- Create indexes for better query performance
CREATE INDEX IF NOT EXISTS idx_polls_related_article_id ON polls(related_article_id);
CREATE INDEX IF NOT EXISTS idx_polls_related_event_id ON polls(related_event_id);
CREATE INDEX IF NOT EXISTS idx_polls_related_video_url ON polls(related_video_url);

-- Add comments for documentation
COMMENT ON COLUMN polls.related_article_id IS 'Link poll to a blog article';
COMMENT ON COLUMN polls.related_event_id IS 'Link poll to an event/activity';
COMMENT ON COLUMN polls.related_video_url IS 'Link poll to a YouTube video URL or ID';
