From ecf91763a64508c29e268b582bb1ac1b1e61ee36 Mon Sep 17 00:00:00 2001 From: shenjiayi Date: Wed, 26 Aug 2020 15:52:48 +0800 Subject: [PATCH] [ongeki] fix chapter jewel not saved --- .../sega/ongeki/model/userdata/UserStory.java | 8 +++++ .../V24__fix_ongeki_user_story_table.sql | 5 +++ .../V24__fix_ongeki_user_story_table.sql | 36 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 src/main/resources/db/migration/mysql/V24__fix_ongeki_user_story_table.sql create mode 100644 src/main/resources/db/migration/sqlite/V24__fix_ongeki_user_story_table.sql diff --git a/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserStory.java b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserStory.java index 41a2c4eb..32a1c9c7 100644 --- a/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserStory.java +++ b/src/main/java/icu/samnyan/aqua/sega/ongeki/model/userdata/UserStory.java @@ -34,6 +34,14 @@ public class UserStory implements Serializable { private int lastChapterId; + private int jewelCount; + + private int lastPlayMusicId; + + private int lastPlayMusicCategory; + + private int lastPlayMusicLevel; + public UserStory(UserData userData) { this.user = userData; } diff --git a/src/main/resources/db/migration/mysql/V24__fix_ongeki_user_story_table.sql b/src/main/resources/db/migration/mysql/V24__fix_ongeki_user_story_table.sql new file mode 100644 index 00000000..86178ef2 --- /dev/null +++ b/src/main/resources/db/migration/mysql/V24__fix_ongeki_user_story_table.sql @@ -0,0 +1,5 @@ +ALTER TABLE `ongeki_user_story` + ADD COLUMN `jewel_count` int(11), + ADD COLUMN `last_play_music_id` int(11), + ADD COLUMN `last_play_music_category` int(11), + ADD COLUMN `last_play_music_level` int(11); diff --git a/src/main/resources/db/migration/sqlite/V24__fix_ongeki_user_story_table.sql b/src/main/resources/db/migration/sqlite/V24__fix_ongeki_user_story_table.sql new file mode 100644 index 00000000..fa6e1a8e --- /dev/null +++ b/src/main/resources/db/migration/sqlite/V24__fix_ongeki_user_story_table.sql @@ -0,0 +1,36 @@ +PRAGMA foreign_keys = 0; + +CREATE TABLE ongeki_user_story_new ( + id INTEGER, + last_chapter_id INTEGER NOT NULL, + story_id INTEGER NOT NULL, + jewel_count INTEGER, + last_play_music_id INTEGER, + last_play_music_category INTEGER, + last_play_music_level INTEGER, + user_id BIGINT REFERENCES ongeki_user_data (id) ON DELETE CASCADE, + PRIMARY KEY ( + id + ), + CONSTRAINT ongeki_user_story_uq UNIQUE ( + story_id, + user_id + ) ON CONFLICT REPLACE +); + +INSERT INTO ongeki_user_story_new ( + id, + last_chapter_id, + story_id, + user_id +) +SELECT id, + last_chapter_id, + story_id, + user_id +FROM ongeki_user_story; + +ALTER TABLE ongeki_user_story RENAME TO bak_ongeki_user_story; +ALTER TABLE ongeki_user_story_new RENAME TO ongeki_user_story; + +PRAGMA foreign_keys = 1;