-- V8: Add vote (like/dislike) support and IP/browser meta to posts

-- likecollect: add explicit action column ('like' or 'dislike')
ALTER TABLE likecollect ADD COLUMN action VARCHAR(20);

-- discussion: add dislike counter
ALTER TABLE discussion ADD COLUMN dislike_count INTEGER DEFAULT 0;

-- post: add per-post vote counters
ALTER TABLE post ADD COLUMN like_count INTEGER DEFAULT 0;
ALTER TABLE post ADD COLUMN dislike_count INTEGER DEFAULT 0;

-- indexes for vote lookup
CREATE INDEX IF NOT EXISTS idx_likecollect_user_discussion ON likecollect(user_id, discussion_id);
CREATE INDEX IF NOT EXISTS idx_likecollect_user_post ON likecollect(user_id, post_id);

-- post: add IP region and parsed browser name
ALTER TABLE post ADD COLUMN ip_region VARCHAR(100);
ALTER TABLE post ADD COLUMN browser VARCHAR(200);
