Add Flyway migrations V3-V5 and database backup

- V3: Add venue_type, result fields, project venue_id
- V4: Create contact, exception_event, judge_project, team tables
- V5: Create schedule_plan, slot, conflict, adjustment_log tables
- Add full database backup 20260113

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
2026-01-15 15:56:28 +08:00
co-authored by factory-droid[bot]
parent 77b324cd4c
commit fd3cc6aa54
4 changed files with 3759 additions and 0 deletions
File diff suppressed because one or more lines are too long
@@ -0,0 +1,51 @@
-- =====================================================
-- 迁移脚本: 添加缺失的字段和表
-- 版本: V3
-- 描述: 补充 venue_type, result 字段, 以及新增表
-- 日期: 2026-01-13
-- =====================================================
-- 1. martial_venue 添加 venue_type 字段
SET @exist := (SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'martial_venue'
AND column_name = 'venue_type');
SET @sql := IF(@exist = 0,
'ALTER TABLE martial_venue ADD COLUMN venue_type varchar(50) DEFAULT NULL COMMENT "场地类型(indoor-室内,outdoor-室外)" AFTER venue_code',
'SELECT 1');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- 2. martial_result 添加评分相关字段
SET @exist := (SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'martial_result'
AND column_name = 'chief_judge_score');
SET @sql := IF(@exist = 0,
'ALTER TABLE martial_result
ADD COLUMN chief_judge_score decimal(10,2) DEFAULT NULL COMMENT "主裁判评分" AFTER publish_time,
ADD COLUMN chief_judge_id bigint DEFAULT NULL COMMENT "主裁判ID" AFTER chief_judge_score,
ADD COLUMN chief_judge_time datetime DEFAULT NULL COMMENT "主裁判评分时间" AFTER chief_judge_id,
ADD COLUMN chief_judge_note varchar(500) DEFAULT NULL COMMENT "主裁判备注" AFTER chief_judge_time,
ADD COLUMN general_judge_score decimal(10,2) DEFAULT NULL COMMENT "副裁判评分" AFTER chief_judge_note,
ADD COLUMN general_judge_id bigint DEFAULT NULL COMMENT "副裁判ID" AFTER general_judge_score,
ADD COLUMN general_judge_time datetime DEFAULT NULL COMMENT "副裁判评分时间" AFTER general_judge_id,
ADD COLUMN general_judge_note varchar(500) DEFAULT NULL COMMENT "副裁判备注" AFTER general_judge_time,
ADD COLUMN score_status int DEFAULT 0 COMMENT "评分状态" AFTER general_judge_note',
'SELECT 1');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- 3. martial_project 添加 venue_id 字段
SET @exist := (SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'martial_project'
AND column_name = 'venue_id');
SET @sql := IF(@exist = 0,
'ALTER TABLE martial_project ADD COLUMN venue_id bigint DEFAULT NULL COMMENT "场地ID" AFTER competition_id',
'SELECT 1');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
@@ -0,0 +1,103 @@
-- =====================================================
-- 迁移脚本: 创建缺失的表
-- 版本: V4
-- 描述: 创建 contact, exception_event, judge_project, team 等表
-- 日期: 2026-01-13
-- =====================================================
-- 1. martial_contact 联系人表
CREATE TABLE IF NOT EXISTS martial_contact (
id bigint NOT NULL,
user_id bigint DEFAULT NULL COMMENT '用户ID',
name varchar(100) DEFAULT NULL COMMENT '联系人姓名',
phone varchar(20) DEFAULT NULL COMMENT '联系电话',
organization varchar(200) DEFAULT NULL COMMENT '所属单位',
is_default tinyint DEFAULT 0 COMMENT '是否默认',
tenant_id varchar(12) DEFAULT '000000',
create_user bigint DEFAULT NULL,
create_dept bigint DEFAULT NULL,
create_time datetime DEFAULT NULL,
update_user bigint DEFAULT NULL,
update_time datetime DEFAULT NULL,
status int DEFAULT 1,
is_deleted int DEFAULT 0,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='联系人表';
-- 2. martial_exception_event 异常事件表
CREATE TABLE IF NOT EXISTS martial_exception_event (
id bigint NOT NULL,
competition_id bigint DEFAULT NULL COMMENT '赛事ID',
schedule_id bigint DEFAULT NULL COMMENT '编排ID',
athlete_id bigint DEFAULT NULL COMMENT '运动员ID',
event_type varchar(50) DEFAULT NULL COMMENT '事件类型',
description text COMMENT '事件描述',
handler_id bigint DEFAULT NULL COMMENT '处理人ID',
handle_time datetime DEFAULT NULL COMMENT '处理时间',
handle_result text COMMENT '处理结果',
tenant_id varchar(12) DEFAULT '000000',
create_user bigint DEFAULT NULL,
create_dept bigint DEFAULT NULL,
create_time datetime DEFAULT NULL,
update_user bigint DEFAULT NULL,
update_time datetime DEFAULT NULL,
status int DEFAULT 1,
is_deleted int DEFAULT 0,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='异常事件表';
-- 3. martial_judge_project 裁判项目关联表
CREATE TABLE IF NOT EXISTS martial_judge_project (
id bigint NOT NULL,
judge_id bigint DEFAULT NULL COMMENT '裁判ID',
project_id bigint DEFAULT NULL COMMENT '项目ID',
competition_id bigint DEFAULT NULL COMMENT '赛事ID',
role_type varchar(50) DEFAULT NULL COMMENT '角色类型',
tenant_id varchar(12) DEFAULT '000000',
create_user bigint DEFAULT NULL,
create_dept bigint DEFAULT NULL,
create_time datetime DEFAULT NULL,
update_user bigint DEFAULT NULL,
update_time datetime DEFAULT NULL,
status int DEFAULT 1,
is_deleted int DEFAULT 0,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='裁判项目关联表';
-- 4. martial_team 团队表
CREATE TABLE IF NOT EXISTS martial_team (
id bigint NOT NULL,
competition_id bigint DEFAULT NULL COMMENT '赛事ID',
project_id bigint DEFAULT NULL COMMENT '项目ID',
order_id bigint DEFAULT NULL COMMENT '订单ID',
team_name varchar(200) DEFAULT NULL COMMENT '团队名称',
organization varchar(200) DEFAULT NULL COMMENT '所属单位',
member_count int DEFAULT 0 COMMENT '成员数量',
tenant_id varchar(12) DEFAULT '000000',
create_user bigint DEFAULT NULL,
create_dept bigint DEFAULT NULL,
create_time datetime DEFAULT NULL,
update_user bigint DEFAULT NULL,
update_time datetime DEFAULT NULL,
status int DEFAULT 1,
is_deleted int DEFAULT 0,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='团队表';
-- 5. martial_team_member 团队成员表
CREATE TABLE IF NOT EXISTS martial_team_member (
id bigint NOT NULL,
team_id bigint DEFAULT NULL COMMENT '团队ID',
athlete_id bigint DEFAULT NULL COMMENT '运动员ID',
role varchar(50) DEFAULT NULL COMMENT '角色',
sequence int DEFAULT 0 COMMENT '顺序',
tenant_id varchar(12) DEFAULT '000000',
create_user bigint DEFAULT NULL,
create_dept bigint DEFAULT NULL,
create_time datetime DEFAULT NULL,
update_user bigint DEFAULT NULL,
update_time datetime DEFAULT NULL,
status int DEFAULT 1,
is_deleted int DEFAULT 0,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='团队成员表';
@@ -0,0 +1,103 @@
-- =====================================================
-- 迁移脚本: 创建编排相关表
-- 版本: V5
-- 描述: 创建 schedule_plan, schedule_slot 等编排表
-- 日期: 2026-01-13
-- =====================================================
-- 1. martial_schedule_plan 编排方案表
CREATE TABLE IF NOT EXISTS martial_schedule_plan (
id bigint NOT NULL,
competition_id bigint DEFAULT NULL COMMENT '赛事ID',
plan_name varchar(200) DEFAULT NULL COMMENT '方案名称',
plan_type varchar(50) DEFAULT NULL COMMENT '方案类型',
is_active tinyint DEFAULT 0 COMMENT '是否激活',
tenant_id varchar(12) DEFAULT '000000',
create_user bigint DEFAULT NULL,
create_dept bigint DEFAULT NULL,
create_time datetime DEFAULT NULL,
update_user bigint DEFAULT NULL,
update_time datetime DEFAULT NULL,
status int DEFAULT 1,
is_deleted int DEFAULT 0,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='编排方案表';
-- 2. martial_schedule_slot 编排时间槽表
CREATE TABLE IF NOT EXISTS martial_schedule_slot (
id bigint NOT NULL,
competition_id bigint DEFAULT NULL COMMENT '赛事ID',
venue_id bigint DEFAULT NULL COMMENT '场地ID',
slot_date date DEFAULT NULL COMMENT '日期',
start_time time DEFAULT NULL COMMENT '开始时间',
end_time time DEFAULT NULL COMMENT '结束时间',
slot_type varchar(50) DEFAULT NULL COMMENT '时间槽类型',
tenant_id varchar(12) DEFAULT '000000',
create_user bigint DEFAULT NULL,
create_dept bigint DEFAULT NULL,
create_time datetime DEFAULT NULL,
update_user bigint DEFAULT NULL,
update_time datetime DEFAULT NULL,
status int DEFAULT 1,
is_deleted int DEFAULT 0,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='编排时间槽表';
-- 3. martial_schedule_athlete_slot 运动员时间槽关联表
CREATE TABLE IF NOT EXISTS martial_schedule_athlete_slot (
id bigint NOT NULL,
slot_id bigint DEFAULT NULL COMMENT '时间槽ID',
athlete_id bigint DEFAULT NULL COMMENT '运动员ID',
schedule_id bigint DEFAULT NULL COMMENT '编排ID',
sequence int DEFAULT 0 COMMENT '顺序',
tenant_id varchar(12) DEFAULT '000000',
create_user bigint DEFAULT NULL,
create_dept bigint DEFAULT NULL,
create_time datetime DEFAULT NULL,
update_user bigint DEFAULT NULL,
update_time datetime DEFAULT NULL,
status int DEFAULT 1,
is_deleted int DEFAULT 0,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='运动员时间槽关联表';
-- 4. martial_schedule_conflict 编排冲突表
CREATE TABLE IF NOT EXISTS martial_schedule_conflict (
id bigint NOT NULL,
competition_id bigint DEFAULT NULL COMMENT '赛事ID',
athlete_id bigint DEFAULT NULL COMMENT '运动员ID',
schedule_id_1 bigint DEFAULT NULL COMMENT '编排ID1',
schedule_id_2 bigint DEFAULT NULL COMMENT '编排ID2',
conflict_type varchar(50) DEFAULT NULL COMMENT '冲突类型',
resolved tinyint DEFAULT 0 COMMENT '是否已解决',
tenant_id varchar(12) DEFAULT '000000',
create_user bigint DEFAULT NULL,
create_dept bigint DEFAULT NULL,
create_time datetime DEFAULT NULL,
update_user bigint DEFAULT NULL,
update_time datetime DEFAULT NULL,
status int DEFAULT 1,
is_deleted int DEFAULT 0,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='编排冲突表';
-- 5. martial_schedule_adjustment_log 编排调整日志表
CREATE TABLE IF NOT EXISTS martial_schedule_adjustment_log (
id bigint NOT NULL,
competition_id bigint DEFAULT NULL COMMENT '赛事ID',
schedule_id bigint DEFAULT NULL COMMENT '编排ID',
adjustment_type varchar(50) DEFAULT NULL COMMENT '调整类型',
before_value text COMMENT '调整前值',
after_value text COMMENT '调整后值',
reason varchar(500) DEFAULT NULL COMMENT '调整原因',
operator_id bigint DEFAULT NULL COMMENT '操作人ID',
tenant_id varchar(12) DEFAULT '000000',
create_user bigint DEFAULT NULL,
create_dept bigint DEFAULT NULL,
create_time datetime DEFAULT NULL,
update_user bigint DEFAULT NULL,
update_time datetime DEFAULT NULL,
status int DEFAULT 1,
is_deleted int DEFAULT 0,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='编排调整日志表';