feat: Add review_helpful_votes table (OQI-002)

Created table to track user votes on course reviews:
- education.review_helpful_votes
- Constraint: one vote per user per review
- Indexes on user_id and review_id

This table supports the "mark as helpful" feature in course reviews.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Adrian Flores Cortes 2026-01-28 12:40:21 -06:00
parent 551091d26a
commit 70c201da8e

View File

@ -0,0 +1,26 @@
-- =====================================================
-- TABLE: education.review_helpful_votes
-- =====================================================
-- Proyecto: OrbiQuant IA (Trading Platform)
-- Módulo: OQI-002 - Education
-- Especificación: Votos de "útil" en reviews de cursos
-- =====================================================
CREATE TABLE education.review_helpful_votes (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
review_id UUID NOT NULL REFERENCES education.course_reviews(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT unique_user_review_vote UNIQUE(user_id, review_id)
);
-- Índices
CREATE INDEX idx_review_helpful_votes_user ON education.review_helpful_votes(user_id);
CREATE INDEX idx_review_helpful_votes_review ON education.review_helpful_votes(review_id);
-- Comentarios
COMMENT ON TABLE education.review_helpful_votes IS 'Votos de usuarios que encontraron útil una review';
COMMENT ON CONSTRAINT unique_user_review_vote ON education.review_helpful_votes IS 'Un usuario solo puede votar una vez por review';