-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdatabase.sql
More file actions
45 lines (40 loc) · 1.54 KB
/
Copy pathdatabase.sql
File metadata and controls
45 lines (40 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- running this will empty your old database and create a new one
DROP SCHEMA IF EXISTS mmjs;
CREATE SCHEMA IF NOT EXISTS mmjs;
USE mmjs;
DROP TABLE IF EXISTS mmjs.Folders;
CREATE TABLE IF NOT EXISTS mmjs.Folders (
FolderID int NOT NULL AUTO_INCREMENT,
Path varchar(512) NOT NULL UNIQUE,
ParentID int DEFAULT NULL REFERENCES Folders(FolderID),
PRIMARY KEY (FolderID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS mmjs.Tracks;
CREATE TABLE IF NOT EXISTS mmjs.Tracks (
TrackID int NOT NULL AUTO_INCREMENT,
Path varchar(512) NOT NULL UNIQUE,
FolderID int NOT NULL,
Title varchar(191) DEFAULT NULL,
Album varchar(191) DEFAULT NULL,
Artist varchar(191) DEFAULT NULL,
Genre varchar(191) DEFAULT NULL,
Year int DEFAULT NULL,
Plays int DEFAULT 0,
PRIMARY KEY (TrackID),
FOREIGN KEY (FolderID) REFERENCES Folders(FolderID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS mmjs.Playlists;
CREATE TABLE IF NOT EXISTS mmjs.Playlists (
PlaylistID int NOT NULL AUTO_INCREMENT,
Name varchar(191) NOT NULL UNIQUE,
PRIMARY KEY (PlaylistID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS mmjs.PlaylistEntries;
CREATE TABLE IF NOT EXISTS mmjs.PlaylistEntries (
PlaylistEntryID int NOT NULL AUTO_INCREMENT,
TrackID int NOT NULL,
PlaylistID int NOT NULL,
FOREIGN KEY (TrackID) REFERENCES Tracks(TrackID),
FOREIGN KEY (PlaylistID) REFERENCES Playlists(PlaylistID),
PRIMARY KEY (PlaylistEntryID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;