From c7e493d7f562672ff24217f9af0e2eca938bb9ca Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Mon, 26 Feb 2024 17:05:32 -0500 Subject: [PATCH] [F] Fix null --- .../db/migration/mariadb/V255_2__fix_null.sql | 17 +++++++++++++++++ .../db/migration/mysql/V255_2__fix_null.sql | 17 +++++++++++++++++ .../db/migration/sqlite/V255_2__fix_null.sql | 3 +++ 3 files changed, 37 insertions(+) create mode 100644 src/main/resources/db/migration/mariadb/V255_2__fix_null.sql create mode 100644 src/main/resources/db/migration/mysql/V255_2__fix_null.sql create mode 100644 src/main/resources/db/migration/sqlite/V255_2__fix_null.sql diff --git a/src/main/resources/db/migration/mariadb/V255_2__fix_null.sql b/src/main/resources/db/migration/mariadb/V255_2__fix_null.sql new file mode 100644 index 00000000..8254961f --- /dev/null +++ b/src/main/resources/db/migration/mariadb/V255_2__fix_null.sql @@ -0,0 +1,17 @@ +-- maimai2_user_playlog +-- Set ext_bool1 as NOT NULL and give it a default value (e.g., FALSE) +UPDATE maimai2_user_playlog SET ext_bool1 = FALSE WHERE ext_bool1 IS NULL; +ALTER TABLE maimai2_user_playlog MODIFY COLUMN ext_bool1 BOOLEAN NOT NULL DEFAULT FALSE; + +-- Set ext_num4 as NOT NULL (assuming it already has a default value of 0) +UPDATE maimai2_user_playlog SET ext_num4 = 0 WHERE ext_num4 IS NULL; +ALTER TABLE maimai2_user_playlog MODIFY COLUMN ext_num4 INTEGER NOT NULL DEFAULT 0; + +-- maimai2_user_detail +-- Add default value for current_play_count and set it as NOT NULL +UPDATE maimai2_user_detail SET current_play_count = 0 WHERE current_play_count IS NULL; +ALTER TABLE maimai2_user_detail MODIFY COLUMN current_play_count INTEGER NOT NULL DEFAULT 0; + +-- Add default value for rename_credit and set it as NOT NULL +UPDATE maimai2_user_detail SET rename_credit = 0 WHERE rename_credit IS NULL; +ALTER TABLE maimai2_user_detail MODIFY COLUMN rename_credit INTEGER NOT NULL DEFAULT 0; diff --git a/src/main/resources/db/migration/mysql/V255_2__fix_null.sql b/src/main/resources/db/migration/mysql/V255_2__fix_null.sql new file mode 100644 index 00000000..8254961f --- /dev/null +++ b/src/main/resources/db/migration/mysql/V255_2__fix_null.sql @@ -0,0 +1,17 @@ +-- maimai2_user_playlog +-- Set ext_bool1 as NOT NULL and give it a default value (e.g., FALSE) +UPDATE maimai2_user_playlog SET ext_bool1 = FALSE WHERE ext_bool1 IS NULL; +ALTER TABLE maimai2_user_playlog MODIFY COLUMN ext_bool1 BOOLEAN NOT NULL DEFAULT FALSE; + +-- Set ext_num4 as NOT NULL (assuming it already has a default value of 0) +UPDATE maimai2_user_playlog SET ext_num4 = 0 WHERE ext_num4 IS NULL; +ALTER TABLE maimai2_user_playlog MODIFY COLUMN ext_num4 INTEGER NOT NULL DEFAULT 0; + +-- maimai2_user_detail +-- Add default value for current_play_count and set it as NOT NULL +UPDATE maimai2_user_detail SET current_play_count = 0 WHERE current_play_count IS NULL; +ALTER TABLE maimai2_user_detail MODIFY COLUMN current_play_count INTEGER NOT NULL DEFAULT 0; + +-- Add default value for rename_credit and set it as NOT NULL +UPDATE maimai2_user_detail SET rename_credit = 0 WHERE rename_credit IS NULL; +ALTER TABLE maimai2_user_detail MODIFY COLUMN rename_credit INTEGER NOT NULL DEFAULT 0; diff --git a/src/main/resources/db/migration/sqlite/V255_2__fix_null.sql b/src/main/resources/db/migration/sqlite/V255_2__fix_null.sql new file mode 100644 index 00000000..88ab48e1 --- /dev/null +++ b/src/main/resources/db/migration/sqlite/V255_2__fix_null.sql @@ -0,0 +1,3 @@ +UPDATE maimai2_user_playlog SET ext_bool1=false; +UPDATE maimai2_user_detail SET current_play_count=0; +UPDATE maimai2_user_detail SET rename_credit=0; \ No newline at end of file