CREATE TABLE chusan_net_battle_log
(
    id                               BIGINT AUTO_INCREMENT NOT NULL,
    user_id                          BIGINT                NULL,
    room_id                          BIGINT                NOT NULL,
    track                            INT                   NOT NULL,
    music_id                         INT                   NOT NULL,
    difficulty_id                    INT                   NOT NULL,
    score                            INT                   NOT NULL,
    select_user_id                   BIGINT                NOT NULL,
    select_user_name                 VARCHAR(64)           NULL,
    opponent_user_id1                BIGINT                NOT NULL,
    opponent_user_id2                BIGINT                NOT NULL,
    opponent_user_id3                BIGINT                NOT NULL,
    opponent_user_name1              VARCHAR(64)           NULL,
    opponent_user_name2              VARCHAR(64)           NULL,
    opponent_user_name3              VARCHAR(64)           NULL,
    opponent_region_id1              INT                   NOT NULL,
    opponent_region_id2              INT                   NOT NULL,
    opponent_region_id3              INT                   NOT NULL,
    opponent_rating1                 INT                   NOT NULL,
    opponent_rating2                 INT                   NOT NULL,
    opponent_rating3                 INT                   NOT NULL,
    opponent_battle_rank_id1         INT                   NOT NULL,
    opponent_battle_rank_id2         INT                   NOT NULL,
    opponent_battle_rank_id3         INT                   NOT NULL,
    opponent_class_emblem_medal1     INT                   NOT NULL,
    opponent_class_emblem_medal2     INT                   NOT NULL,
    opponent_class_emblem_medal3     INT                   NOT NULL,
    opponent_class_emblem_base1      INT                   NOT NULL,
    opponent_class_emblem_base2      INT                   NOT NULL,
    opponent_class_emblem_base3      INT                   NOT NULL,
    opponent_score1                  INT                   NOT NULL,
    opponent_score2                  INT                   NOT NULL,
    opponent_score3                  INT                   NOT NULL,
    opponent_chara_illust_id1        INT                   NOT NULL,
    opponent_chara_illust_id2        INT                   NOT NULL,
    opponent_chara_illust_id3        INT                   NOT NULL,
    opponent_chara_lv1               INT                   NOT NULL,
    opponent_chara_lv2               INT                   NOT NULL,
    opponent_chara_lv3               INT                   NOT NULL,
    opponent_rating_effect_color_id1 INT                   NOT NULL,
    opponent_rating_effect_color_id2 INT                   NOT NULL,
    opponent_rating_effect_color_id3 INT                   NOT NULL,
    battle_rule_id                   INT                   NOT NULL,
    month_po_long                    INT                   NOT NULL,
    event_po_long                    INT                   NOT NULL,
    CONSTRAINT pk_chusan_net_battle_log PRIMARY KEY (id)
);

ALTER TABLE chusan_net_battle_log
    ADD CONSTRAINT FK_CHUSAN_NET_BATTLE_LOG_ON_USER FOREIGN KEY (user_id) REFERENCES chusan_user_data (id);
