2021-03-27 05:33:44 +00:00
|
|
|
START TRANSACTION;
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS `links` (
|
|
|
|
`scrobble` BINARY(16) NOT NULL,
|
|
|
|
`track` BINARY(16) NOT NULL,
|
|
|
|
PRIMARY KEY (`scrobble`, `track`),
|
|
|
|
KEY `trackLookup` (`track`)
|
|
|
|
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS `artists` (
|
|
|
|
`uuid` BINARY(16) PRIMARY KEY,
|
2021-03-28 08:52:34 +00:00
|
|
|
`name` VARCHAR(255) NOT NULL,
|
2021-03-27 05:33:44 +00:00
|
|
|
`desc` TEXT,
|
2021-03-28 08:52:34 +00:00
|
|
|
`img` VARCHAR(255) DEFAULT NULL
|
2021-03-27 05:33:44 +00:00
|
|
|
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS `albums` (
|
|
|
|
`uuid` BINARY(16) PRIMARY KEY,
|
2021-03-28 08:52:34 +00:00
|
|
|
`name` VARCHAR(255) NOT NULL,
|
2021-03-27 05:33:44 +00:00
|
|
|
`desc` TEXT,
|
2021-03-28 08:52:34 +00:00
|
|
|
`img` VARCHAR(255) DEFAULT NULL
|
2021-03-27 05:33:44 +00:00
|
|
|
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS `tracks` (
|
|
|
|
`uuid` BINARY(16) PRIMARY KEY,
|
2021-03-28 08:52:34 +00:00
|
|
|
`name` VARCHAR(255) NOT NULL,
|
2021-03-27 05:33:44 +00:00
|
|
|
`desc` TEXT,
|
2021-03-28 08:52:34 +00:00
|
|
|
`img` VARCHAR(255) DEFAULT NULL
|
2021-03-27 05:33:44 +00:00
|
|
|
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS `scrobbles` (
|
|
|
|
`uuid` BINARY(16) PRIMARY KEY,
|
|
|
|
`created_at` DATETIME NOT NULL,
|
|
|
|
`created_ip` VARBINARY(16) NULL DEFAULT NULL,
|
|
|
|
`user` BINARY(16) NOT NULL,
|
|
|
|
`track` BINARY(16) NOT NULL,
|
2021-04-01 10:17:46 +00:00
|
|
|
`source` VARCHAR(100) NOT NULL DEFAULT '',
|
2021-03-27 05:33:44 +00:00
|
|
|
KEY `userLookup` (`user`),
|
|
|
|
KEY `dateLookup` (`created_at`),
|
2021-04-01 10:17:46 +00:00
|
|
|
KEY `sourceLookup` (`source`),
|
2021-03-27 05:33:44 +00:00
|
|
|
FOREIGN KEY (track) REFERENCES tracks(uuid),
|
|
|
|
FOREIGN KEY (user) REFERENCES users(uuid)
|
|
|
|
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
|
|
|
|
2021-03-28 08:52:34 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS `album_artist` (
|
|
|
|
`album` BINARY(16) NOT NULL,
|
2021-03-27 05:33:44 +00:00
|
|
|
`artist` BINARY(16) NOT NULL,
|
2021-03-28 08:52:34 +00:00
|
|
|
PRIMARY KEY (`album`, `artist`),
|
|
|
|
FOREIGN KEY (album) REFERENCES albums(uuid),
|
2021-03-27 05:33:44 +00:00
|
|
|
FOREIGN KEY (artist) REFERENCES artists(uuid)
|
|
|
|
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
|
|
|
|
2021-03-28 08:52:34 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS `track_album` (
|
|
|
|
`track` BINARY(16) NOT NULL,
|
2021-03-27 05:33:44 +00:00
|
|
|
`album` BINARY(16) NOT NULL,
|
2021-03-28 08:52:34 +00:00
|
|
|
PRIMARY KEY (`track`, `album`),
|
|
|
|
FOREIGN KEY (track) REFERENCES tracks(uuid),
|
|
|
|
FOREIGN KEY (album) REFERENCES albums(uuid)
|
|
|
|
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS `track_artist` (
|
|
|
|
`track` BINARY(16) NOT NULL,
|
2021-03-27 05:33:44 +00:00
|
|
|
`artist` BINARY(16) NOT NULL,
|
2021-03-28 08:52:34 +00:00
|
|
|
PRIMARY KEY (`track`, `artist`),
|
|
|
|
FOREIGN KEY (track) REFERENCES tracks(uuid),
|
2021-03-27 05:33:44 +00:00
|
|
|
FOREIGN KEY (artist) REFERENCES artists(uuid)
|
|
|
|
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
|
|
|
|
|
|
|
COMMIT;
|