-- Ongeki user option: stealth_field, color_wall_bright,
CREATE TABLE "ongeki_user_option_new" (
    id INTEGER,
    "abort" INTEGER NOT NULL,
    color_field INTEGER NOT NULL,
    color_lane INTEGER NOT NULL,
    color_lane_bright INTEGER NOT NULL,
    color_side INTEGER NOT NULL,
    color_wall_bright INTEGER NOT NULL,
    dispbp INTEGER NOT NULL,
    disp_player_lv INTEGER NOT NULL,
    disp_rating INTEGER NOT NULL,
    effect_damage INTEGER NOT NULL,
    effect_pos INTEGER NOT NULL,
    headphone INTEGER NOT NULL,
    judge_break INTEGER NOT NULL,
    judge_disp INTEGER NOT NULL,
    judge_hit INTEGER NOT NULL,
    judge_pos INTEGER NOT NULL,
    judge_timing INTEGER NOT NULL,
    judge_adjustment INTEGER,
    judge_critical_break INTEGER,
    matching INTEGER NOT NULL,
    mirror INTEGER NOT NULL,
    option_set INTEGER NOT NULL,
    speed INTEGER NOT NULL,
    stealth_field INTEGER NOT NULL,
    tap_sound INTEGER NOT NULL,
    platinum_break_disp INTEGER,
    vol_all INTEGER NOT NULL,
    vol_bell INTEGER NOT NULL,
    vol_cr_tap INTEGER NOT NULL,
    vol_damage INTEGER NOT NULL,
    vol_enemy INTEGER NOT NULL,
    vol_flick INTEGER NOT NULL,
    vol_guide INTEGER NOT NULL,
    vol_hold INTEGER NOT NULL,
    vol_side INTEGER NOT NULL,
    vol_skill INTEGER NOT NULL,
    vol_tap INTEGER NOT NULL,
    user_id BIGINT REFERENCES ongeki_user_data (id) ON DELETE CASCADE UNIQUE ON CONFLICT REPLACE,
    PRIMARY KEY (id)
);

INSERT INTO
    ongeki_user_option_new (
        id,
        "abort",
        color_field,
        color_lane,
        color_lane_bright,
        color_side,
        dispbp,
        disp_player_lv,
        disp_rating,
        effect_damage,
        effect_pos,
        headphone,
        judge_break,
        judge_disp,
        judge_hit,
        judge_pos,
        judge_timing,
        judge_adjustment,
        judge_critical_break,
        matching,
        mirror,
        option_set,
        speed,
        tap_sound,
        platinum_break_disp,
        vol_all,
        vol_bell,
        vol_cr_tap,
        vol_damage,
        vol_enemy,
        vol_flick,
        vol_guide,
        vol_hold,
        vol_side,
        vol_skill,
        vol_tap,
        user_id,
        color_wall_bright,
        stealth_field
    )
SELECT
    id,
    "abort",
    color_field,
    color_lane,
    color_lane_bright,
    color_side,
    dispbp,
    disp_player_lv,
    disp_rating,
    effect_damage,
    effect_pos,
    headphone,
    judge_break,
    judge_disp,
    judge_hit,
    judge_pos,
    judge_timing,
    judge_adjustment,
    judge_critical_break,
    matching,
    mirror,
    option_set,
    speed,
    tap_sound,
    platinum_break_disp,
    vol_all,
    vol_bell,
    vol_cr_tap,
    vol_damage,
    vol_enemy,
    vol_flick,
    vol_guide,
    vol_hold,
    vol_side,
    vol_skill,
    vol_tap,
    user_id,
    0,
    3
FROM
    ongeki_user_option;

ALTER TABLE
    ongeki_user_option RENAME TO bak4_ongeki_user_option;

ALTER TABLE
    ongeki_user_option_new RENAME TO ongeki_user_option;

-- Ongeki user data: best_battle_point, over_damage_battle_point, rival_score_category_setting, last_emoney_brand
CREATE TABLE ongeki_user_data_new (
    id INTEGER,
    battle_point INTEGER NOT NULL,
    best_battle_point INTEGER NOT NULL,
    over_damage_battle_point INTEGER NOT NULL,
    card_category_setting INTEGER NOT NULL,
    card_id INTEGER NOT NULL,
    card_sort_setting INTEGER NOT NULL,
    character_id INTEGER NOT NULL,
    compatible_cm_version VARCHAR(255),
    event_watched_date VARCHAR(255),
    exp BIGINT NOT NULL,
    first_data_version VARCHAR(255),
    first_game_id VARCHAR(255),
    first_play_date VARCHAR(255),
    first_rom_version VARCHAR(255),
    first_tutorial_cancel_num INTEGER NOT NULL,
    highest_rating INTEGER NOT NULL,
    jewel_count INTEGER NOT NULL,
    last_all_net_id INTEGER NOT NULL,
    last_client_id VARCHAR(255),
    last_data_version VARCHAR(255),
    last_game_id VARCHAR(255),
    last_place_id INTEGER NOT NULL,
    last_place_name VARCHAR(255),
    last_play_date VARCHAR(255),
    last_play_music_level INTEGER NOT NULL,
    last_region_id INTEGER NOT NULL,
    last_region_name VARCHAR(255),
    last_rom_version VARCHAR(255),
    last_used_deck_id INTEGER NOT NULL,
    last_emoney_brand INTEGER NOT NULL,
    level INTEGER NOT NULL,
    nameplate_id INTEGER NOT NULL,
    play_count INTEGER NOT NULL,
    played_tutorial_bit INTEGER NOT NULL,
    player_rating INTEGER NOT NULL,
    point BIGINT NOT NULL,
    reincarnation_num INTEGER NOT NULL,
    rival_score_category_setting INTEGER NOT NULL,
    sum_battle_advanced_high_score BIGINT NOT NULL,
    sum_battle_basic_high_score BIGINT NOT NULL,
    sum_battle_expert_high_score BIGINT NOT NULL,
    sum_battle_high_score BIGINT NOT NULL,
    sum_battle_lunatic_high_score BIGINT NOT NULL,
    sum_battle_master_high_score BIGINT NOT NULL,
    sum_tech_advanced_high_score BIGINT NOT NULL,
    sum_tech_basic_high_score BIGINT NOT NULL,
    sum_tech_expert_high_score BIGINT NOT NULL,
    sum_tech_high_score BIGINT NOT NULL,
    sum_tech_lunatic_high_score BIGINT NOT NULL,
    sum_tech_master_high_score BIGINT NOT NULL,
    tab_setting INTEGER NOT NULL,
    tab_sort_setting INTEGER NOT NULL,
    total_jewel_count INTEGER NOT NULL,
    total_point BIGINT NOT NULL,
    trophy_id INTEGER NOT NULL,
    medal_count INTEGER,
    cm_event_watched_date VARCHAR(255),
    user_name VARCHAR(255),
    aime_card_id BIGINT REFERENCES sega_card (id) ON DELETE CASCADE,
    PRIMARY KEY (id)
);

INSERT INTO
    ongeki_user_data_new(
        id,
        battle_point,
        card_category_setting,
        card_id,
        card_sort_setting,
        character_id,
        compatible_cm_version,
        event_watched_date,
        exp,
        first_data_version,
        first_game_id,
        first_play_date,
        first_rom_version,
        first_tutorial_cancel_num,
        highest_rating,
        jewel_count,
        last_all_net_id,
        last_client_id,
        last_data_version,
        last_game_id,
        last_place_id,
        last_place_name,
        last_play_date,
        last_play_music_level,
        last_region_id,
        last_region_name,
        last_rom_version,
        last_used_deck_id,
        level,
        nameplate_id,
        play_count,
        played_tutorial_bit,
        player_rating,
        point,
        reincarnation_num,
        sum_battle_advanced_high_score,
        sum_battle_basic_high_score,
        sum_battle_expert_high_score,
        sum_battle_high_score,
        sum_battle_lunatic_high_score,
        sum_battle_master_high_score,
        sum_tech_advanced_high_score,
        sum_tech_basic_high_score,
        sum_tech_expert_high_score,
        sum_tech_high_score,
        sum_tech_lunatic_high_score,
        sum_tech_master_high_score,
        tab_setting,
        tab_sort_setting,
        total_jewel_count,
        total_point,
        trophy_id,
        medal_count,
        cm_event_watched_date,
        user_name,
        aime_card_id,
        best_battle_point,
        over_damage_battle_point,
        rival_score_category_setting,
        last_emoney_brand
    )
SELECT
    id,
    battle_point,
    card_category_setting,
    card_id,
    card_sort_setting,
    character_id,
    compatible_cm_version,
    event_watched_date,
    exp,
    first_data_version,
    first_game_id,
    first_play_date,
    first_rom_version,
    first_tutorial_cancel_num,
    highest_rating,
    jewel_count,
    last_all_net_id,
    last_client_id,
    last_data_version,
    last_game_id,
    last_place_id,
    last_place_name,
    last_play_date,
    last_play_music_level,
    last_region_id,
    last_region_name,
    last_rom_version,
    last_used_deck_id,
    level,
    nameplate_id,
    play_count,
    played_tutorial_bit,
    player_rating,
    point,
    reincarnation_num,
    sum_battle_advanced_high_score,
    sum_battle_basic_high_score,
    sum_battle_expert_high_score,
    sum_battle_high_score,
    sum_battle_lunatic_high_score,
    sum_battle_master_high_score,
    sum_tech_advanced_high_score,
    sum_tech_basic_high_score,
    sum_tech_expert_high_score,
    sum_tech_high_score,
    sum_tech_lunatic_high_score,
    sum_tech_master_high_score,
    tab_setting,
    tab_sort_setting,
    total_jewel_count,
    total_point,
    trophy_id,
    medal_count,
    cm_event_watched_date,
    user_name,
    aime_card_id,
    battle_point,
    0,
    0,
    0
FROM
    ongeki_user_data;

ALTER TABLE
    ongeki_user_data RENAME TO bak2_ongeki_user_data;

ALTER TABLE
    ongeki_user_data_new RENAME TO ongeki_user_data;