From a17589d540bb3904c8a7293f40baef39d2323dc7 Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Mon, 15 Feb 2016 16:30:43 -0600 Subject: [PATCH] Added defaults for Playlist object. --- .../com/jdbernard/wdiwtlt/db/models/Playlist.java | 12 +++++++----- .../migrations/20151209054632-initial-schema-up.sql | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/jdbernard/wdiwtlt/db/models/Playlist.java b/core/src/main/java/com/jdbernard/wdiwtlt/db/models/Playlist.java index 36437ff..f6b8375 100644 --- a/core/src/main/java/com/jdbernard/wdiwtlt/db/models/Playlist.java +++ b/core/src/main/java/com/jdbernard/wdiwtlt/db/models/Playlist.java @@ -4,12 +4,14 @@ import java.sql.Timestamp; import java.util.Date; public class Playlist extends Model { - public boolean userCreated; + public boolean userCreated = false; public Timestamp lastUsed = new Timestamp(new Date().getTime()); public String name; - public int modCount; - public int mediaFileCount; - public Integer copiedFromId; + public int modCount = 0; + public int mediaFileCount = 0; + public Integer copiedFromId = null; - public String toString() { return name; } + public String toString() { + if (userCreated) return name; + return name + " (auto)"; } } diff --git a/core/src/main/sql/migrations/20151209054632-initial-schema-up.sql b/core/src/main/sql/migrations/20151209054632-initial-schema-up.sql index 203c25f..3e578bc 100644 --- a/core/src/main/sql/migrations/20151209054632-initial-schema-up.sql +++ b/core/src/main/sql/migrations/20151209054632-initial-schema-up.sql @@ -52,7 +52,7 @@ CREATE TABLE playlists ( name VARCHAR NOT NULL, mod_count INTEGER NOT NULL DEFAULT 0, media_file_count INTEGER NOT NULL DEFAULT 0, - copied_from_id INTEGER REFERENCES playlists(id) + copied_from_id INTEGER REFERENCES playlists(id) DEFAULT NULL ); CREATE TABLE playlists_media_files (