Add track_number and track_total. Added indexes on item names.

This commit is contained in:
Jonathan Bernard 2016-02-09 15:28:04 -06:00
parent d72ce4467f
commit b605b56221
3 changed files with 14 additions and 2 deletions

View File

@ -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; }
}

View File

@ -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;

View File

@ -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,