-- ============================================================
-- Migration: 영상 반응(좋아요) 테이블 추가
-- Date: 2026-05-21
-- Description: 사용자 영상별 좋아요 토글 (1인 1회, 확장 가능한 구조)
-- ============================================================

CREATE TABLE IF NOT EXISTS video_reaction (
    id         BIGINT      NOT NULL AUTO_INCREMENT COMMENT '고유 식별자',
    video_id   INT         NOT NULL                COMMENT '연결된 Video의 id',
    user_uuid  VARCHAR(36) NOT NULL                COMMENT '반응한 사용자 UUID',
    created_at DATETIME    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '반응 일시',
    PRIMARY KEY (id),
    CONSTRAINT uq_video_reaction_user_video UNIQUE (user_uuid, video_id),
    CONSTRAINT fk_video_reaction_video FOREIGN KEY (video_id)  REFERENCES video(id)         ON DELETE CASCADE,
    CONSTRAINT fk_video_reaction_user  FOREIGN KEY (user_uuid) REFERENCES `user`(user_uuid) ON DELETE CASCADE,
    INDEX idx_video_reaction_video_id  (video_id),
    INDEX idx_video_reaction_user_uuid (user_uuid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
  COMMENT='영상 반응 (user_uuid + video_id 유니크)';
