1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-23 01:16:18 +00:00
supysonic/schema/mysql.sql

124 lines
3.8 KiB
MySQL
Raw Normal View History

2014-06-12 12:09:14 +00:00
CREATE TABLE folder (
id BINARY(16) PRIMARY KEY,
2014-06-12 12:09:14 +00:00
root BOOLEAN NOT NULL,
name VARCHAR(256) NOT NULL,
path VARCHAR(4096) NOT NULL,
created DATETIME NOT NULL,
has_cover_art BOOLEAN NOT NULL,
last_scan INTEGER NOT NULL,
parent_id BINARY(16) REFERENCES folder
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE artist (
id BINARY(16) PRIMARY KEY,
2014-06-12 12:09:14 +00:00
name VARCHAR(256) NOT NULL
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE album (
id BINARY(16) PRIMARY KEY,
2014-06-12 12:09:14 +00:00
name VARCHAR(256) NOT NULL,
artist_id BINARY(16) NOT NULL REFERENCES artist
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE track (
id BINARY(16) PRIMARY KEY,
2014-06-12 12:09:14 +00:00
disc INTEGER NOT NULL,
number INTEGER NOT NULL,
title VARCHAR(256) NOT NULL,
year INTEGER,
genre VARCHAR(256),
duration INTEGER NOT NULL,
album_id BINARY(16) NOT NULL REFERENCES album,
artist_id BINARY(16) NOT NULL REFERENCES artist,
2014-06-12 12:09:14 +00:00
bitrate INTEGER NOT NULL,
path VARCHAR(4096) NOT NULL,
content_type VARCHAR(32) NOT NULL,
created DATETIME NOT NULL,
last_modification INTEGER NOT NULL,
play_count INTEGER NOT NULL,
last_play DATETIME,
root_folder_id BINARY(16) NOT NULL REFERENCES folder,
folder_id BINARY(16) NOT NULL REFERENCES folder
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE user (
id BINARY(16) PRIMARY KEY,
2014-06-12 12:09:14 +00:00
name VARCHAR(64) NOT NULL,
mail VARCHAR(256),
password CHAR(40) NOT NULL,
salt CHAR(6) NOT NULL,
admin BOOLEAN NOT NULL,
lastfm_session CHAR(32),
lastfm_status BOOLEAN NOT NULL,
last_play_id BINARY(16) REFERENCES track,
2014-06-12 12:09:14 +00:00
last_play_date DATETIME
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE client_prefs (
user_id BINARY(16) NOT NULL,
2014-06-12 12:09:14 +00:00
client_name VARCHAR(32) NOT NULL,
format VARCHAR(8),
bitrate INTEGER,
PRIMARY KEY (user_id, client_name)
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE starred_folder (
user_id BINARY(16) NOT NULL REFERENCES user,
starred_id BINARY(16) NOT NULL REFERENCES folder,
2014-06-12 12:09:14 +00:00
date DATETIME NOT NULL,
PRIMARY KEY (user_id, starred_id)
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE starred_artist (
user_id BINARY(16) NOT NULL REFERENCES user,
starred_id BINARY(16) NOT NULL REFERENCES artist,
2014-06-12 12:09:14 +00:00
date DATETIME NOT NULL,
PRIMARY KEY (user_id, starred_id)
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE starred_album (
user_id BINARY(16) NOT NULL REFERENCES user,
starred_id BINARY(16) NOT NULL REFERENCES album,
2014-06-12 12:09:14 +00:00
date DATETIME NOT NULL,
PRIMARY KEY (user_id, starred_id)
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE starred_track (
user_id BINARY(16) NOT NULL REFERENCES user,
starred_id BINARY(16) NOT NULL REFERENCES track,
2014-06-12 12:09:14 +00:00
date DATETIME NOT NULL,
PRIMARY KEY (user_id, starred_id)
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE rating_folder (
user_id BINARY(16) NOT NULL REFERENCES user,
rated_id BINARY(16) NOT NULL REFERENCES folder,
2014-06-12 12:09:14 +00:00
rating INTEGER NOT NULL CHECK(rating BETWEEN 1 AND 5),
PRIMARY KEY (user_id, rated_id)
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE rating_track (
user_id BINARY(16) NOT NULL REFERENCES user,
rated_id BINARY(16) NOT NULL REFERENCES track,
2014-06-12 12:09:14 +00:00
rating INTEGER NOT NULL CHECK(rating BETWEEN 1 AND 5),
PRIMARY KEY (user_id, rated_id)
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE chat_message (
id BINARY(16) PRIMARY KEY,
user_id BINARY(16) NOT NULL REFERENCES user,
2014-06-12 12:09:14 +00:00
time INTEGER NOT NULL,
message VARCHAR(512) NOT NULL
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00
CREATE TABLE playlist (
id BINARY(16) PRIMARY KEY,
user_id BINARY(16) NOT NULL REFERENCES user,
2014-06-12 12:09:14 +00:00
name VARCHAR(256) NOT NULL,
comment VARCHAR(256),
public BOOLEAN NOT NULL,
created DATETIME NOT NULL,
tracks TEXT
2018-02-21 20:55:00 +00:00
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2014-06-12 12:09:14 +00:00