1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 17:06:17 +00:00

Fixed MySQL schema using broken UTF-8

This commit is contained in:
spl0k 2018-02-21 21:55:00 +01:00
parent 43b197a95e
commit 3005e529a2
2 changed files with 74 additions and 14 deletions

View File

@ -0,0 +1,60 @@
ALTER TABLE folder DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE artist DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE album DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE track DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE user DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE client_prefs DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE starred_folder DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE starred_artist DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE starred_album DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE starred_track DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE rating_folder DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE rating_track DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE chat_message DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE playlist DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE folder CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE artist CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE album CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE track CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE user CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE client_prefs CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE starred_folder CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE starred_artist CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE starred_album CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE starred_track CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE rating_folder CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE rating_track CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE chat_message CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE playlist CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
REPAIR TABLE folder;
REPAIR TABLE artist;
REPAIR TABLE album;
REPAIR TABLE track;
REPAIR TABLE user;
REPAIR TABLE client_prefs;
REPAIR TABLE starred_folder;
REPAIR TABLE starred_artist;
REPAIR TABLE starred_album;
REPAIR TABLE starred_track;
REPAIR TABLE rating_folder;
REPAIR TABLE rating_track;
REPAIR TABLE chat_message;
REPAIR TABLE playlist;
OPTIMIZE TABLE folder;
OPTIMIZE TABLE artist;
OPTIMIZE TABLE album;
OPTIMIZE TABLE track;
OPTIMIZE TABLE user;
OPTIMIZE TABLE client_prefs;
OPTIMIZE TABLE starred_folder;
OPTIMIZE TABLE starred_artist;
OPTIMIZE TABLE starred_album;
OPTIMIZE TABLE starred_track;
OPTIMIZE TABLE rating_folder;
OPTIMIZE TABLE rating_track;
OPTIMIZE TABLE chat_message;
OPTIMIZE TABLE playlist;

View File

@ -7,18 +7,18 @@ CREATE TABLE folder (
has_cover_art BOOLEAN NOT NULL, has_cover_art BOOLEAN NOT NULL,
last_scan INTEGER NOT NULL, last_scan INTEGER NOT NULL,
parent_id BINARY(16) REFERENCES folder parent_id BINARY(16) REFERENCES folder
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE artist ( CREATE TABLE artist (
id BINARY(16) PRIMARY KEY, id BINARY(16) PRIMARY KEY,
name VARCHAR(256) NOT NULL name VARCHAR(256) NOT NULL
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE album ( CREATE TABLE album (
id BINARY(16) PRIMARY KEY, id BINARY(16) PRIMARY KEY,
name VARCHAR(256) NOT NULL, name VARCHAR(256) NOT NULL,
artist_id BINARY(16) NOT NULL REFERENCES artist artist_id BINARY(16) NOT NULL REFERENCES artist
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE track ( CREATE TABLE track (
id BINARY(16) PRIMARY KEY, id BINARY(16) PRIMARY KEY,
@ -39,7 +39,7 @@ CREATE TABLE track (
last_play DATETIME, last_play DATETIME,
root_folder_id BINARY(16) NOT NULL REFERENCES folder, root_folder_id BINARY(16) NOT NULL REFERENCES folder,
folder_id BINARY(16) NOT NULL REFERENCES folder folder_id BINARY(16) NOT NULL REFERENCES folder
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE user ( CREATE TABLE user (
id BINARY(16) PRIMARY KEY, id BINARY(16) PRIMARY KEY,
@ -52,7 +52,7 @@ CREATE TABLE user (
lastfm_status BOOLEAN NOT NULL, lastfm_status BOOLEAN NOT NULL,
last_play_id BINARY(16) REFERENCES track, last_play_id BINARY(16) REFERENCES track,
last_play_date DATETIME last_play_date DATETIME
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE client_prefs ( CREATE TABLE client_prefs (
user_id BINARY(16) NOT NULL, user_id BINARY(16) NOT NULL,
@ -60,56 +60,56 @@ CREATE TABLE client_prefs (
format VARCHAR(8), format VARCHAR(8),
bitrate INTEGER, bitrate INTEGER,
PRIMARY KEY (user_id, client_name) PRIMARY KEY (user_id, client_name)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE starred_folder ( CREATE TABLE starred_folder (
user_id BINARY(16) NOT NULL REFERENCES user, user_id BINARY(16) NOT NULL REFERENCES user,
starred_id BINARY(16) NOT NULL REFERENCES folder, starred_id BINARY(16) NOT NULL REFERENCES folder,
date DATETIME NOT NULL, date DATETIME NOT NULL,
PRIMARY KEY (user_id, starred_id) PRIMARY KEY (user_id, starred_id)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE starred_artist ( CREATE TABLE starred_artist (
user_id BINARY(16) NOT NULL REFERENCES user, user_id BINARY(16) NOT NULL REFERENCES user,
starred_id BINARY(16) NOT NULL REFERENCES artist, starred_id BINARY(16) NOT NULL REFERENCES artist,
date DATETIME NOT NULL, date DATETIME NOT NULL,
PRIMARY KEY (user_id, starred_id) PRIMARY KEY (user_id, starred_id)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE starred_album ( CREATE TABLE starred_album (
user_id BINARY(16) NOT NULL REFERENCES user, user_id BINARY(16) NOT NULL REFERENCES user,
starred_id BINARY(16) NOT NULL REFERENCES album, starred_id BINARY(16) NOT NULL REFERENCES album,
date DATETIME NOT NULL, date DATETIME NOT NULL,
PRIMARY KEY (user_id, starred_id) PRIMARY KEY (user_id, starred_id)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE starred_track ( CREATE TABLE starred_track (
user_id BINARY(16) NOT NULL REFERENCES user, user_id BINARY(16) NOT NULL REFERENCES user,
starred_id BINARY(16) NOT NULL REFERENCES track, starred_id BINARY(16) NOT NULL REFERENCES track,
date DATETIME NOT NULL, date DATETIME NOT NULL,
PRIMARY KEY (user_id, starred_id) PRIMARY KEY (user_id, starred_id)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE rating_folder ( CREATE TABLE rating_folder (
user_id BINARY(16) NOT NULL REFERENCES user, user_id BINARY(16) NOT NULL REFERENCES user,
rated_id BINARY(16) NOT NULL REFERENCES folder, rated_id BINARY(16) NOT NULL REFERENCES folder,
rating INTEGER NOT NULL CHECK(rating BETWEEN 1 AND 5), rating INTEGER NOT NULL CHECK(rating BETWEEN 1 AND 5),
PRIMARY KEY (user_id, rated_id) PRIMARY KEY (user_id, rated_id)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE rating_track ( CREATE TABLE rating_track (
user_id BINARY(16) NOT NULL REFERENCES user, user_id BINARY(16) NOT NULL REFERENCES user,
rated_id BINARY(16) NOT NULL REFERENCES track, rated_id BINARY(16) NOT NULL REFERENCES track,
rating INTEGER NOT NULL CHECK(rating BETWEEN 1 AND 5), rating INTEGER NOT NULL CHECK(rating BETWEEN 1 AND 5),
PRIMARY KEY (user_id, rated_id) PRIMARY KEY (user_id, rated_id)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE chat_message ( CREATE TABLE chat_message (
id BINARY(16) PRIMARY KEY, id BINARY(16) PRIMARY KEY,
user_id BINARY(16) NOT NULL REFERENCES user, user_id BINARY(16) NOT NULL REFERENCES user,
time INTEGER NOT NULL, time INTEGER NOT NULL,
message VARCHAR(512) NOT NULL message VARCHAR(512) NOT NULL
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE playlist ( CREATE TABLE playlist (
id BINARY(16) PRIMARY KEY, id BINARY(16) PRIMARY KEY,
@ -119,5 +119,5 @@ CREATE TABLE playlist (
public BOOLEAN NOT NULL, public BOOLEAN NOT NULL,
created DATETIME NOT NULL, created DATETIME NOT NULL,
tracks TEXT tracks TEXT
) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;