diff --git a/service/src/main/java/com/jdbernard/wdiwtlt/db/models/Album.java b/service/src/main/java/com/jdbernard/wdiwtlt/db/models/Album.java index baf11b7..9ffa93e 100644 --- a/service/src/main/java/com/jdbernard/wdiwtlt/db/models/Album.java +++ b/service/src/main/java/com/jdbernard/wdiwtlt/db/models/Album.java @@ -4,7 +4,10 @@ package com.jdbernard.wdiwtlt.db.models; public class Album { public int id; public String name; + public Integer trackTotal; public Integer year; - public String toString() { return name + " (" + year + ")"; } + public String toString() { + if (year != null) return name + " (" + year + ")"; + else return name; } } diff --git a/service/src/main/java/com/jdbernard/wdiwtlt/db/models/MediaFile.java b/service/src/main/java/com/jdbernard/wdiwtlt/db/models/MediaFile.java index e50c085..7b2fac4 100644 --- a/service/src/main/java/com/jdbernard/wdiwtlt/db/models/MediaFile.java +++ b/service/src/main/java/com/jdbernard/wdiwtlt/db/models/MediaFile.java @@ -7,6 +7,7 @@ public class MediaFile { public int id; public String name; + public Integer trackNumber; public int playCount = 0; public String filePath; public String fileHash; diff --git a/service/src/main/sql/migrations/20151209054632-initial-schema-up.sql b/service/src/main/sql/migrations/20151209054632-initial-schema-up.sql index fae4151..7c2ca11 100644 --- a/service/src/main/sql/migrations/20151209054632-initial-schema-up.sql +++ b/service/src/main/sql/migrations/20151209054632-initial-schema-up.sql @@ -3,15 +3,21 @@ CREATE TABLE artists ( name VARCHAR UNIQUE NOT NULL ); +CREATE INDEX artists_name_idx ON artists(name); + CREATE TABLE albums ( id SERIAL PRIMARY KEY, name VARCHAR NOT NULL, - year INTEGER + year INTEGER, + track_total INTEGER ); +CREATE INDEX albums_name_idx ON albums(name); + CREATE TABLE media_files ( id SERIAL PRIMARY KEY, name VARCHAR NOT NULL, + track_number INTEGER, play_count INTEGER NOT NULL DEFAULT 0, file_path VARCHAR NOT NULL, file_hash VARCHAR NOT NULL, @@ -19,6 +25,8 @@ CREATE TABLE media_files ( comment VARCHAR DEFAULT '' ); +CREATE INDEX media_files_name_idx ON media_files(name); + CREATE TABLE artists_media_files ( artist_id INTEGER NOT NULL REFERENCES artists(id) ON DELETE CASCADE, media_file_id INTEGER NOT NULL REFERENCES media_files(id) ON DELETE CASCADE,