PRAGMA foreign_keys = 0;

CREATE TABLE diva_player_profile_new (
                                     id                              INTEGER,
                                     button_se                       INTEGER       NOT NULL,
                                     button_se_on                    BOOLEAN       NOT NULL,
                                     button_se_volume                INTEGER       NOT NULL,
                                     chain_slide_se                  INTEGER       NOT NULL,
                                     common_customize_items          VARCHAR (255),
                                     common_module                   VARCHAR (255),
                                     common_module_set_time          DATETIME,
                                     common_skin                     INTEGER       NOT NULL,
                                     contest_now_playing_enable      BOOLEAN       NOT NULL,
                                     contest_now_playing_id          INTEGER       NOT NULL,
                                     contest_now_playing_result_rank VARCHAR (255),
                                     contest_now_playing_specifier   VARCHAR (255),
                                     contest_now_playing_value       INTEGER       NOT NULL,
                                     headphone_volume                INTEGER       NOT NULL,
                                     level                           INTEGER       NOT NULL,
                                     level_exp                       INTEGER       NOT NULL,
                                     level_title                     VARCHAR (255),
                                     module_select_item_flag         VARCHAR (255),
                                     my_list0                        VARCHAR (255),
                                     my_list1                        VARCHAR (255),
                                     my_list2                        VARCHAR (255),
                                     next_difficulty                 VARCHAR (255),
                                     next_edition                    VARCHAR (255),
                                     next_pv_id                      INTEGER       NOT NULL,
                                     password                        VARCHAR (255),
                                     password_status                 VARCHAR (255),
                                     pd_id                           INTEGER       UNIQUE
                                         REFERENCES sega_card (ext_id) ON DELETE CASCADE,
                                     plate_effect_id                 INTEGER       NOT NULL,
                                     plate_id                        INTEGER       NOT NULL,
                                     player_name                     VARCHAR (255),
                                     prefer_common_module            BOOLEAN       NOT NULL,
                                     prefer_per_pv_module            BOOLEAN       NOT NULL,
                                     show_great_border               BOOLEAN       NOT NULL,
                                     show_clear_status               BOOLEAN       NOT NULL,
                                     show_interim_ranking            BOOLEAN       NOT NULL,
                                     show_rgo_setting                BOOLEAN       NOT NULL,
                                     slide_se                        INTEGER       NOT NULL,
                                     slider_se_volume                INTEGER       NOT NULL,
                                     slider_touch_se                 INTEGER       NOT NULL,
                                     sort_mode                       VARCHAR (255),
                                     use_per_pv_button_se            BOOLEAN       NOT NULL,
                                     use_per_pv_chain_slider_se      BOOLEAN       NOT NULL,
                                     use_per_pv_skin                 BOOLEAN       NOT NULL,
                                     use_per_pv_slider_se            BOOLEAN       NOT NULL,
                                     use_per_pv_touch_slider_se      BOOLEAN       NOT NULL,
                                     vocaloid_points                 INTEGER       NOT NULL,
                                     show_excellent_border           BOOLEAN       NOT NULL,
                                     show_rival_border               BOOLEAN       NOT NULL,
                                     rival_pd_id                     INTEGER       NOT NULL,
                                     PRIMARY KEY (
                                                  id
                                         )
);

INSERT INTO diva_player_profile_new (
    id,
    button_se,
    button_se_on,
    button_se_volume,
    chain_slide_se,
    common_customize_items,
    common_module,
    common_module_set_time,
    common_skin,
    contest_now_playing_enable,
    contest_now_playing_id,
    contest_now_playing_result_rank,
    contest_now_playing_specifier,
    contest_now_playing_value,
    headphone_volume,
    level,
    level_exp,
    level_title,
    module_select_item_flag,
    my_list0,
    my_list1,
    my_list2,
    next_difficulty,
    next_edition,
    next_pv_id,
    password,
    password_status,
    pd_id,
    plate_effect_id,
    plate_id,
    player_name,
    prefer_common_module,
    prefer_per_pv_module,
    show_great_border,
    show_clear_status,
    show_interim_ranking,
    show_rgo_setting,
    slide_se,
    slider_se_volume,
    slider_touch_se,
    sort_mode,
    use_per_pv_button_se,
    use_per_pv_chain_slider_se,
    use_per_pv_skin,
    use_per_pv_slider_se,
    use_per_pv_touch_slider_se,
    vocaloid_points,
    show_excellent_border,
    show_rival_border,
    rival_pd_id
)
SELECT id,
       button_se,
       button_se_on,
       button_se_volume,
       chain_slide_se,
       common_customize_items,
       common_module,
       common_module_set_time,
       common_skin,
       contest_now_playing_enable,
       contest_now_playing_id,
       contest_now_playing_result_rank,
       contest_now_playing_specifier,
       contest_now_playing_value,
       headphone_volume,
       level,
       level_exp,
       level_title,
       module_select_item_flag,
       my_list0,
       my_list1,
       my_list2,
       next_difficulty,
       next_edition,
       next_pv_id,
       password,
       password_status,
       pd_id,
       plate_effect_id,
       plate_id,
       player_name,
       prefer_common_module,
       prefer_per_pv_module,
       show_clear_border,
       show_clear_status,
       show_interim_ranking,
       show_rgo_setting,
       slide_se,
       slider_se_volume,
       slider_touch_se,
       sort_mode,
       use_per_pv_button_se,
       use_per_pv_chain_slider_se,
       use_per_pv_skin,
       use_per_pv_slider_se,
       use_per_pv_touch_slider_se,
       vocaloid_points,
       1,
       1,
       -1
FROM diva_player_profile;

ALTER TABLE diva_player_profile RENAME TO bak_diva_player_profile;
ALTER TABLE diva_player_profile_new RENAME TO diva_player_profile;

PRAGMA foreign_keys = 1;
