mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-12-25 16:19:00 +00:00
Build out track schemas
This commit is contained in:
parent
c9c6946891
commit
a22f282a6d
8
migrations/3_tracks.down.sql
Normal file
8
migrations/3_tracks.down.sql
Normal file
@ -0,0 +1,8 @@
|
||||
START TRANSACTION;
|
||||
DROP TABLE IF EXISTS `artists`;
|
||||
DROP TABLE IF EXISTS `albums`;
|
||||
DROP TABLE IF EXISTS `tracks`;
|
||||
DROP TABLE IF EXISTS `track_artist`;
|
||||
DROP TABLE IF EXISTS `scrobble_track`;
|
||||
|
||||
COMMIT;
|
59
migrations/3_tracks.up.sql
Normal file
59
migrations/3_tracks.up.sql
Normal file
@ -0,0 +1,59 @@
|
||||
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,
|
||||
`name` BINARY(16) NOT NULL,
|
||||
`desc` TEXT,
|
||||
`img` VARCHAR(255) DEFAULT ''
|
||||
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `albums` (
|
||||
`uuid` BINARY(16) PRIMARY KEY,
|
||||
`name` BINARY(16) NOT NULL,
|
||||
`desc` TEXT,
|
||||
`img` VARCHAR(255) DEFAULT ''
|
||||
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tracks` (
|
||||
`uuid` BINARY(16) PRIMARY KEY,
|
||||
`name` BINARY(16) NOT NULL,
|
||||
`desc` TEXT,
|
||||
`img` VARCHAR(255) DEFAULT ''
|
||||
) 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,
|
||||
KEY `userLookup` (`user`),
|
||||
KEY `dateLookup` (`created_at`),
|
||||
FOREIGN KEY (track) REFERENCES tracks(uuid),
|
||||
FOREIGN KEY (user) REFERENCES users(uuid)
|
||||
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `track_artist` (
|
||||
`track` BINARY(16) NOT NULL,
|
||||
`artist` BINARY(16) NOT NULL,
|
||||
PRIMARY KEY (`track`, `artist`),
|
||||
FOREIGN KEY (track) REFERENCES tracks(uuid),
|
||||
FOREIGN KEY (artist) REFERENCES artists(uuid)
|
||||
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `album_artist` (
|
||||
`album` BINARY(16) NOT NULL,
|
||||
`artist` BINARY(16) NOT NULL,
|
||||
PRIMARY KEY (`album`, `artist`),
|
||||
FOREIGN KEY (album) REFERENCES albums(uuid),
|
||||
FOREIGN KEY (artist) REFERENCES artists(uuid)
|
||||
) DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci;
|
||||
|
||||
COMMIT;
|
Loading…
Reference in New Issue
Block a user