-- 创建裁判-项目关联表
-- 日期: 2025-11-30
-- 功能: 管理裁判对项目的评分权限

CREATE TABLE IF NOT EXISTS martial_judge_project (
    id BIGINT PRIMARY KEY COMMENT 'ID',
    tenant_id VARCHAR(12) DEFAULT '000000' COMMENT '租户ID',
    competition_id BIGINT NOT NULL COMMENT '赛事ID',
    judge_id BIGINT NOT NULL COMMENT '裁判ID',
    project_id BIGINT NOT NULL COMMENT '项目ID',
    assign_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '分配时间',
    status INT DEFAULT 1 COMMENT '状态 0-禁用 1-启用',
    create_user BIGINT COMMENT '创建人',
    create_dept BIGINT COMMENT '创建部门',
    create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    update_user BIGINT COMMENT '更新人',
    update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    is_deleted INT DEFAULT 0 COMMENT '是否已删除 0-未删除 1-已删除',
    UNIQUE KEY uk_judge_project (competition_id, judge_id, project_id, is_deleted)
) COMMENT '裁判项目关联表';

-- 创建索引
CREATE INDEX idx_judge_id ON martial_judge_project(judge_id);
CREATE INDEX idx_project_id ON martial_judge_project(project_id);
CREATE INDEX idx_competition_id ON martial_judge_project(competition_id);
