aboutsummaryrefslogtreecommitdiff
path: root/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-07-27 14:33:25 -0700
committerScott Jackson <daneren2005@gmail.com>2013-07-27 14:33:38 -0700
commit4738428c2c205f42200386ae09b44b9ec07b9144 (patch)
treea6402978fe1b4655f90c3c8a181f4d246fbc5e89 /subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema
parent82ec8315f777c319f2372540098e21111019d629 (diff)
downloaddsub-4738428c2c205f42200386ae09b44b9ec07b9144.tar.gz
dsub-4738428c2c205f42200386ae09b44b9ec07b9144.tar.bz2
dsub-4738428c2c205f42200386ae09b44b9ec07b9144.zip
Move subsonic-android to root
Diffstat (limited to 'subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema')
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema.java66
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema25.java81
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema26.java110
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema27.java54
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema28.java110
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema29.java55
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema30.java56
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema31.java52
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema32.java93
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema33.java47
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema34.java53
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema35.java151
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema36.java48
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema37.java77
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema38.java54
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema40.java46
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema43.java65
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema45.java76
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema46.java87
-rw-r--r--subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema47.java234
20 files changed, 0 insertions, 1615 deletions
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema.java
deleted file mode 100644
index 674f85ca..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import org.springframework.jdbc.core.*;
-
-/**
- * Used for creating and evolving the database schema.
- *
- * @author Sindre Mehus
- */
-public abstract class Schema {
-
- /**
- * Executes this schema.
- * @param template The JDBC template to use.
- */
- public abstract void execute(JdbcTemplate template);
-
- /**
- * Returns whether the given table exists.
- * @param template The JDBC template to use.
- * @param table The table in question.
- * @return Whether the table exists.
- */
- protected boolean tableExists(JdbcTemplate template, String table) {
- try {
- template.execute("select 1 from " + table);
- } catch (Exception x) {
- return false;
- }
- return true;
- }
-
- /**
- * Returns whether the given column in the given table exists.
- * @param template The JDBC template to use.
- * @param column The column in question.
- * @param table The table in question.
- * @return Whether the column exists.
- */
- protected boolean columnExists(JdbcTemplate template, String column, String table) {
- try {
- template.execute("select " + column + " from " + table + " where 1 = 0");
- } catch (Exception x) {
- return false;
- }
- return true;
- }
-}
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema25.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema25.java
deleted file mode 100644
index 33cc2525..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema25.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import org.springframework.jdbc.core.*;
-import net.sourceforge.subsonic.*;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implementes the database schema for Subsonic version 2.5.
- *
- * @author Sindre Mehus
- */
-public class Schema25 extends Schema{
- private static final Logger LOG = Logger.getLogger(Schema25.class);
-
- public void execute(JdbcTemplate template) {
- if (!tableExists(template, "version")) {
- LOG.info("Database table 'version' not found. Creating it.");
- template.execute("create table version (version int not null)");
- template.execute("insert into version values (1)");
- LOG.info("Database table 'version' was created successfully.");
- }
-
- if (!tableExists(template, "role")) {
- LOG.info("Database table 'role' not found. Creating it.");
- template.execute("create table role (" +
- "id int not null," +
- "name varchar not null," +
- "primary key (id))");
- template.execute("insert into role values (1, 'admin')");
- template.execute("insert into role values (2, 'download')");
- template.execute("insert into role values (3, 'upload')");
- template.execute("insert into role values (4, 'playlist')");
- template.execute("insert into role values (5, 'coverart')");
- LOG.info("Database table 'role' was created successfully.");
- }
-
- if (!tableExists(template, "user")) {
- LOG.info("Database table 'user' not found. Creating it.");
- template.execute("create table user (" +
- "username varchar not null," +
- "password varchar not null," +
- "primary key (username))");
- template.execute("insert into user values ('admin', 'admin')");
- LOG.info("Database table 'user' was created successfully.");
- }
-
- if (!tableExists(template, "user_role")) {
- LOG.info("Database table 'user_role' not found. Creating it.");
- template.execute("create table user_role (" +
- "username varchar not null," +
- "role_id int not null," +
- "primary key (username, role_id)," +
- "foreign key (username) references user(username)," +
- "foreign key (role_id) references role(id))");
- template.execute("insert into user_role values ('admin', 1)");
- template.execute("insert into user_role values ('admin', 2)");
- template.execute("insert into user_role values ('admin', 3)");
- template.execute("insert into user_role values ('admin', 4)");
- template.execute("insert into user_role values ('admin', 5)");
- LOG.info("Database table 'user_role' was created successfully.");
- }
- }
-}
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema26.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema26.java
deleted file mode 100644
index 6d60b29b..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema26.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.*;
-import net.sourceforge.subsonic.util.Util;
-import org.springframework.jdbc.core.*;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implementes the database schema for Subsonic version 2.6.
- *
- * @author Sindre Mehus
- */
-public class Schema26 extends Schema{
- private static final Logger LOG = Logger.getLogger(Schema26.class);
-
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 2") == 0) {
- LOG.info("Updating database schema to version 2.");
- template.execute("insert into version values (2)");
- }
-
- if (!tableExists(template, "music_folder")) {
- LOG.info("Database table 'music_folder' not found. Creating it.");
- template.execute("create table music_folder (" +
- "id identity," +
- "path varchar not null," +
- "name varchar not null," +
- "enabled boolean not null)");
- template.execute("insert into music_folder values (null, '" + Util.getDefaultMusicFolder() + "', 'Music', true)");
- LOG.info("Database table 'music_folder' was created successfully.");
- }
-
- if (!tableExists(template, "music_file_info")) {
- LOG.info("Database table 'music_file_info' not found. Creating it.");
- template.execute("create cached table music_file_info (" +
- "id identity," +
- "path varchar not null," +
- "rating int," +
- "comment varchar," +
- "play_count int," +
- "last_played datetime)");
- template.execute("create index idx_music_file_info_path on music_file_info(path)");
- LOG.info("Database table 'music_file_info' was created successfully.");
- }
-
- if (!tableExists(template, "internet_radio")) {
- LOG.info("Database table 'internet_radio' not found. Creating it.");
- template.execute("create table internet_radio (" +
- "id identity," +
- "name varchar not null," +
- "stream_url varchar not null," +
- "homepage_url varchar," +
- "enabled boolean not null)");
- LOG.info("Database table 'internet_radio' was created successfully.");
- }
-
- if (!tableExists(template, "player")) {
- LOG.info("Database table 'player' not found. Creating it.");
- template.execute("create table player (" +
- "id int not null," +
- "name varchar," +
- "type varchar," +
- "username varchar," +
- "ip_address varchar," +
- "auto_control_enabled boolean not null," +
- "last_seen datetime," +
- "cover_art_scheme varchar not null," +
- "transcode_scheme varchar not null," +
- "primary key (id))");
- LOG.info("Database table 'player' was created successfully.");
- }
-
- // 'dynamic_ip' was added in 2.6.beta2
- if (!columnExists(template, "dynamic_ip", "player")) {
- LOG.info("Database column 'player.dynamic_ip' not found. Creating it.");
- template.execute("alter table player " +
- "add dynamic_ip boolean default true not null");
- LOG.info("Database column 'player.dynamic_ip' was added successfully.");
- }
-
- if (template.queryForInt("select count(*) from role where id = 6") == 0) {
- LOG.info("Role 'comment' not found in database. Creating it.");
- template.execute("insert into role values (6, 'comment')");
- template.execute("insert into user_role " +
- "select distinct u.username, 6 from user u, user_role ur " +
- "where u.username = ur.username and ur.role_id in (1, 5)");
- LOG.info("Role 'comment' was created successfully.");
- }
- }
-
-}
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema27.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema27.java
deleted file mode 100644
index 4057622e..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema27.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.*;
-import org.springframework.jdbc.core.*;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implementes the database schema for Subsonic version 2.7.
- *
- * @author Sindre Mehus
- */
-public class Schema27 extends Schema{
- private static final Logger LOG = Logger.getLogger(Schema27.class);
-
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 3") == 0) {
- LOG.info("Updating database schema to version 3.");
- template.execute("insert into version values (3)");
-
- LOG.info("Converting database column 'music_file_info.path' to varchar_ignorecase.");
- template.execute("drop index idx_music_file_info_path");
- template.execute("alter table music_file_info alter column path varchar_ignorecase not null");
- template.execute("create index idx_music_file_info_path on music_file_info(path)");
- LOG.info("Database column 'music_file_info.path' was converted successfully.");
- }
-
- if (!columnExists(template, "bytes_streamed", "user")) {
- LOG.info("Database columns 'user.bytes_streamed/downloaded/uploaded' not found. Creating them.");
- template.execute("alter table user add bytes_streamed bigint default 0 not null");
- template.execute("alter table user add bytes_downloaded bigint default 0 not null");
- template.execute("alter table user add bytes_uploaded bigint default 0 not null");
- LOG.info("Database columns 'user.bytes_streamed/downloaded/uploaded' were added successfully.");
- }
- }
-}
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema28.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema28.java
deleted file mode 100644
index dbee6730..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema28.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.*;
-import org.springframework.jdbc.core.*;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implementes the database schema for Subsonic version 2.8.
- *
- * @author Sindre Mehus
- */
-public class Schema28 extends Schema {
- private static final Logger LOG = Logger.getLogger(Schema28.class);
-
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 4") == 0) {
- LOG.info("Updating database schema to version 4.");
- template.execute("insert into version values (4)");
- }
-
- if (!tableExists(template, "user_settings")) {
- LOG.info("Database table 'user_settings' not found. Creating it.");
- template.execute("create table user_settings (" +
- "username varchar not null," +
- "locale varchar," +
- "theme_id varchar," +
- "final_version_notification boolean default true not null," +
- "beta_version_notification boolean default false not null," +
- "main_caption_cutoff int default 35 not null," +
- "main_track_number boolean default true not null," +
- "main_artist boolean default true not null," +
- "main_album boolean default false not null," +
- "main_genre boolean default false not null," +
- "main_year boolean default false not null," +
- "main_bit_rate boolean default false not null," +
- "main_duration boolean default true not null," +
- "main_format boolean default false not null," +
- "main_file_size boolean default false not null," +
- "playlist_caption_cutoff int default 35 not null," +
- "playlist_track_number boolean default false not null," +
- "playlist_artist boolean default true not null," +
- "playlist_album boolean default true not null," +
- "playlist_genre boolean default false not null," +
- "playlist_year boolean default true not null," +
- "playlist_bit_rate boolean default false not null," +
- "playlist_duration boolean default true not null," +
- "playlist_format boolean default true not null," +
- "playlist_file_size boolean default true not null," +
- "primary key (username)," +
- "foreign key (username) references user(username) on delete cascade)");
- LOG.info("Database table 'user_settings' was created successfully.");
- }
-
- if (!tableExists(template, "transcoding")) {
- LOG.info("Database table 'transcoding' not found. Creating it.");
- template.execute("create table transcoding (" +
- "id identity," +
- "name varchar not null," +
- "source_format varchar not null," +
- "target_format varchar not null," +
- "step1 varchar not null," +
- "step2 varchar," +
- "step3 varchar," +
- "enabled boolean not null)");
-
- template.execute("insert into transcoding values(null,'wav > mp3', 'wav', 'mp3','ffmpeg -i %s -v 0 -f wav -','lame -b %b --tt %t --ta %a --tl %l -S --resample 44.1 - -',null,true)");
- template.execute("insert into transcoding values(null,'flac > mp3','flac','mp3','ffmpeg -i %s -v 0 -f wav -','lame -b %b --tt %t --ta %a --tl %l -S --resample 44.1 - -',null,true)");
- template.execute("insert into transcoding values(null,'ogg > mp3' ,'ogg' ,'mp3','ffmpeg -i %s -v 0 -f wav -','lame -b %b --tt %t --ta %a --tl %l -S --resample 44.1 - -',null,true)");
- template.execute("insert into transcoding values(null,'wma > mp3' ,'wma' ,'mp3','ffmpeg -i %s -v 0 -f wav -','lame -b %b --tt %t --ta %a --tl %l -S --resample 44.1 - -',null,true)");
- template.execute("insert into transcoding values(null,'m4a > mp3' ,'m4a' ,'mp3','ffmpeg -i %s -v 0 -f wav -','lame -b %b --tt %t --ta %a --tl %l -S --resample 44.1 - -',null,false)");
- template.execute("insert into transcoding values(null,'aac > mp3' ,'aac' ,'mp3','ffmpeg -i %s -v 0 -f wav -','lame -b %b --tt %t --ta %a --tl %l -S --resample 44.1 - -',null,false)");
- template.execute("insert into transcoding values(null,'ape > mp3' ,'ape' ,'mp3','ffmpeg -i %s -v 0 -f wav -','lame -b %b --tt %t --ta %a --tl %l -S --resample 44.1 - -',null,true)");
- template.execute("insert into transcoding values(null,'mpc > mp3' ,'mpc' ,'mp3','ffmpeg -i %s -v 0 -f wav -','lame -b %b --tt %t --ta %a --tl %l -S --resample 44.1 - -',null,true)");
- template.execute("insert into transcoding values(null,'mv > mp3' ,'mv' ,'mp3','ffmpeg -i %s -v 0 -f wav -','lame -b %b --tt %t --ta %a --tl %l -S --resample 44.1 - -',null,true)");
- template.execute("insert into transcoding values(null,'shn > mp3' ,'shn' ,'mp3','ffmpeg -i %s -v 0 -f wav -','lame -b %b --tt %t --ta %a --tl %l -S --resample 44.1 - -',null,true)");
-
- LOG.info("Database table 'transcoding' was created successfully.");
- }
-
- if (!tableExists(template, "player_transcoding")) {
- LOG.info("Database table 'player_transcoding' not found. Creating it.");
- template.execute("create table player_transcoding (" +
- "player_id int not null," +
- "transcoding_id int not null," +
- "primary key (player_id, transcoding_id)," +
- "foreign key (player_id) references player(id) on delete cascade," +
- "foreign key (transcoding_id) references transcoding(id) on delete cascade)");
- LOG.info("Database table 'player_transcoding' was created successfully.");
- }
- }
-}
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema29.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema29.java
deleted file mode 100644
index dd4748d1..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema29.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.*;
-import org.springframework.jdbc.core.*;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implementes the database schema for Subsonic version 2.9.
- *
- * @author Sindre Mehus
- */
-public class Schema29 extends Schema {
- private static final Logger LOG = Logger.getLogger(Schema29.class);
-
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 5") == 0) {
- LOG.info("Updating database schema to version 5.");
- template.execute("insert into version values (5)");
- }
-
- if (!tableExists(template, "user_rating")) {
- LOG.info("Database table 'user_rating' not found. Creating it.");
- template.execute("create table user_rating (" +
- "username varchar not null," +
- "path varchar not null," +
- "rating double not null," +
- "primary key (username, path)," +
- "foreign key (username) references user(username) on delete cascade)");
- LOG.info("Database table 'user_rating' was created successfully.");
-
- template.execute("insert into user_rating select 'admin', path, rating from music_file_info " +
- "where rating is not null and rating > 0");
- LOG.info("Migrated data from 'music_file_info' to 'user_rating'.");
- }
- }
-}
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema30.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema30.java
deleted file mode 100644
index cdea199b..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema30.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.*;
-import net.sourceforge.subsonic.domain.TranscodeScheme;
-import org.springframework.jdbc.core.*;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implementes the database schema for Subsonic version 3.0.
- *
- * @author Sindre Mehus
- */
-public class Schema30 extends Schema {
- private static final Logger LOG = Logger.getLogger(Schema30.class);
-
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 6") == 0) {
- LOG.info("Updating database schema to version 6.");
- template.execute("insert into version values (6)");
- }
-
- if (!columnExists(template, "last_fm_enabled", "user_settings")) {
- LOG.info("Database columns 'user_settings.last_fm_*' not found. Creating them.");
- template.execute("alter table user_settings add last_fm_enabled boolean default false not null");
- template.execute("alter table user_settings add last_fm_username varchar null");
- template.execute("alter table user_settings add last_fm_password varchar null");
- LOG.info("Database columns 'user_settings.last_fm_*' were added successfully.");
- }
-
- if (!columnExists(template, "transcode_scheme", "user_settings")) {
- LOG.info("Database column 'user_settings.transcode_scheme' not found. Creating it.");
- template.execute("alter table user_settings add transcode_scheme varchar default '" +
- TranscodeScheme.OFF.name() + "' not null");
- LOG.info("Database column 'user_settings.transcode_scheme' was added successfully.");
- }
- }
-} \ No newline at end of file
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema31.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema31.java
deleted file mode 100644
index 00fb0c87..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema31.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.Logger;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implementes the database schema for Subsonic version 3.1.
- *
- * @author Sindre Mehus
- */
-public class Schema31 extends Schema {
- private static final Logger LOG = Logger.getLogger(Schema31.class);
-
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 7") == 0) {
- LOG.info("Updating database schema to version 7.");
- template.execute("insert into version values (7)");
- }
-
- if (!columnExists(template, "enabled", "music_file_info")) {
- LOG.info("Database column 'music_file_info.enabled' not found. Creating it.");
- template.execute("alter table music_file_info add enabled boolean default true not null");
- LOG.info("Database column 'music_file_info.enabled' was added successfully.");
- }
-
- if (!columnExists(template, "default_active", "transcoding")) {
- LOG.info("Database column 'transcoding.default_active' not found. Creating it.");
- template.execute("alter table transcoding add default_active boolean default true not null");
- LOG.info("Database column 'transcoding.default_active' was added successfully.");
- }
- }
-}
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema32.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema32.java
deleted file mode 100644
index a1439bb0..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema32.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.Logger;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implementes the database schema for Subsonic version 3.2.
- *
- * @author Sindre Mehus
- */
-public class Schema32 extends Schema {
- private static final Logger LOG = Logger.getLogger(Schema32.class);
-
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 8") == 0) {
- LOG.info("Updating database schema to version 8.");
- template.execute("insert into version values (8)");
- }
-
- if (!columnExists(template, "show_now_playing", "user_settings")) {
- LOG.info("Database column 'user_settings.show_now_playing' not found. Creating it.");
- template.execute("alter table user_settings add show_now_playing boolean default true not null");
- LOG.info("Database column 'user_settings.show_now_playing' was added successfully.");
- }
-
- if (!columnExists(template, "selected_music_folder_id", "user_settings")) {
- LOG.info("Database column 'user_settings.selected_music_folder_id' not found. Creating it.");
- template.execute("alter table user_settings add selected_music_folder_id int default -1 not null");
- LOG.info("Database column 'user_settings.selected_music_folder_id' was added successfully.");
- }
-
- if (!tableExists(template, "podcast_channel")) {
- LOG.info("Database table 'podcast_channel' not found. Creating it.");
- template.execute("create table podcast_channel (" +
- "id identity," +
- "url varchar not null," +
- "title varchar," +
- "description varchar," +
- "status varchar not null," +
- "error_message varchar)");
- LOG.info("Database table 'podcast_channel' was created successfully.");
- }
-
- if (!tableExists(template, "podcast_episode")) {
- LOG.info("Database table 'podcast_episode' not found. Creating it.");
- template.execute("create table podcast_episode (" +
- "id identity," +
- "channel_id int not null," +
- "url varchar not null," +
- "path varchar," +
- "title varchar," +
- "description varchar," +
- "publish_date datetime," +
- "duration varchar," +
- "bytes_total bigint," +
- "bytes_downloaded bigint," +
- "status varchar not null," +
- "error_message varchar," +
- "foreign key (channel_id) references podcast_channel(id) on delete cascade)");
- LOG.info("Database table 'podcast_episode' was created successfully.");
- }
-
- if (template.queryForInt("select count(*) from role where id = 7") == 0) {
- LOG.info("Role 'podcast' not found in database. Creating it.");
- template.execute("insert into role values (7, 'podcast')");
- template.execute("insert into user_role " +
- "select distinct u.username, 7 from user u, user_role ur " +
- "where u.username = ur.username and ur.role_id = 1");
- LOG.info("Role 'podcast' was created successfully.");
- }
-
- }
-}
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema33.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema33.java
deleted file mode 100644
index 6f754306..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema33.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.Logger;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implementes the database schema for Subsonic version 3.3.
- *
- * @author Sindre Mehus
- */
-public class Schema33 extends Schema {
-
- private static final Logger LOG = Logger.getLogger(Schema33.class);
-
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 9") == 0) {
- LOG.info("Updating database schema to version 9.");
- template.execute("insert into version values (9)");
- }
-
- if (!columnExists(template, "client_side_playlist", "player")) {
- LOG.info("Database column 'player.client_side_playlist' not found. Creating it.");
- template.execute("alter table player add client_side_playlist boolean default false not null");
- LOG.info("Database column 'player.client_side_playlist' was added successfully.");
- }
- }
-}
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema34.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema34.java
deleted file mode 100644
index daaf98ca..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema34.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.Logger;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implementes the database schema for Subsonic version 3.4.
- *
- * @author Sindre Mehus
- */
-public class Schema34 extends Schema {
-
- private static final Logger LOG = Logger.getLogger(Schema34.class);
-
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 10") == 0) {
- LOG.info("Updating database schema to version 10.");
- template.execute("insert into version values (10)");
- }
-
- if (!columnExists(template, "ldap_authenticated", "user")) {
- LOG.info("Database column 'user.ldap_authenticated' not found. Creating it.");
- template.execute("alter table user add ldap_authenticated boolean default false not null");
- LOG.info("Database column 'user.ldap_authenticated' was added successfully.");
- }
-
- if (!columnExists(template, "party_mode_enabled", "user_settings")) {
- LOG.info("Database column 'user_settings.party_mode_enabled' not found. Creating it.");
- template.execute("alter table user_settings add party_mode_enabled boolean default false not null");
- LOG.info("Database column 'user_settings.party_mode_enabled' was added successfully.");
- }
- }
-} \ No newline at end of file
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema35.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema35.java
deleted file mode 100644
index 56b5073d..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema35.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.Logger;
-import org.apache.commons.io.IOUtils;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implementes the database schema for Subsonic version 3.5.
- *
- * @author Sindre Mehus
- */
-public class Schema35 extends Schema {
-
- private static final Logger LOG = Logger.getLogger(Schema35.class);
-
- private static final String[] AVATARS = {
- "Formal", "Engineer", "Footballer", "Green-Boy",
-
- "Linux-Zealot", "Mac-Zealot", "Windows-Zealot", "Army-Officer", "Beatnik",
- "All-Caps", "Clown", "Commie-Pinko", "Forum-Flirt", "Gamer", "Hopelessly-Addicted",
- "Jekyll-And-Hyde", "Joker", "Lurker", "Moderator", "Newbie", "No-Dissent",
- "Performer", "Push-My-Button", "Ray-Of-Sunshine", "Red-Hot-Chili-Peppers-1",
- "Red-Hot-Chili-Peppers-2", "Red-Hot-Chili-Peppers-3", "Red-Hot-Chili-Peppers-4",
- "Ringmaster", "Rumor-Junkie", "Sozzled-Surfer", "Statistician", "Tech-Support",
- "The-Guru", "The-Referee", "Troll", "Uptight",
-
- "Fire-Guitar", "Drum", "Headphones", "Mic", "Turntable", "Vinyl",
-
- "Cool", "Laugh", "Study"
- };
-
- @Override
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 11") == 0) {
- LOG.info("Updating database schema to version 11.");
- template.execute("insert into version values (11)");
- }
-
- if (!columnExists(template, "now_playing_allowed", "user_settings")) {
- LOG.info("Database column 'user_settings.now_playing_allowed' not found. Creating it.");
- template.execute("alter table user_settings add now_playing_allowed boolean default true not null");
- LOG.info("Database column 'user_settings.now_playing_allowed' was added successfully.");
- }
-
- if (!columnExists(template, "web_player_default", "user_settings")) {
- LOG.info("Database column 'user_settings.web_player_default' not found. Creating it.");
- template.execute("alter table user_settings add web_player_default boolean default false not null");
- LOG.info("Database column 'user_settings.web_player_default' was added successfully.");
- }
-
- if (template.queryForInt("select count(*) from role where id = 8") == 0) {
- LOG.info("Role 'stream' not found in database. Creating it.");
- template.execute("insert into role values (8, 'stream')");
- template.execute("insert into user_role select distinct u.username, 8 from user u");
- LOG.info("Role 'stream' was created successfully.");
- }
-
- if (!tableExists(template, "system_avatar")) {
- LOG.info("Database table 'system_avatar' not found. Creating it.");
- template.execute("create table system_avatar (" +
- "id identity," +
- "name varchar," +
- "created_date datetime not null," +
- "mime_type varchar not null," +
- "width int not null," +
- "height int not null," +
- "data binary not null)");
- LOG.info("Database table 'system_avatar' was created successfully.");
- }
-
- for (String avatar : AVATARS) {
- createAvatar(template, avatar);
- }
-
- if (!tableExists(template, "custom_avatar")) {
- LOG.info("Database table 'custom_avatar' not found. Creating it.");
- template.execute("create table custom_avatar (" +
- "id identity," +
- "name varchar," +
- "created_date datetime not null," +
- "mime_type varchar not null," +
- "width int not null," +
- "height int not null," +
- "data binary not null," +
- "username varchar not null," +
- "foreign key (username) references user(username) on delete cascade)");
- LOG.info("Database table 'custom_avatar' was created successfully.");
- }
-
- if (!columnExists(template, "avatar_scheme", "user_settings")) {
- LOG.info("Database column 'user_settings.avatar_scheme' not found. Creating it.");
- template.execute("alter table user_settings add avatar_scheme varchar default 'NONE' not null");
- LOG.info("Database column 'user_settings.avatar_scheme' was added successfully.");
- }
-
- if (!columnExists(template, "system_avatar_id", "user_settings")) {
- LOG.info("Database column 'user_settings.system_avatar_id' not found. Creating it.");
- template.execute("alter table user_settings add system_avatar_id int");
- template.execute("alter table user_settings add foreign key (system_avatar_id) references system_avatar(id)");
- LOG.info("Database column 'user_settings.system_avatar_id' was added successfully.");
- }
-
- if (!columnExists(template, "jukebox", "player")) {
- LOG.info("Database column 'player.jukebox' not found. Creating it.");
- template.execute("alter table player add jukebox boolean default false not null");
- LOG.info("Database column 'player.jukebox' was added successfully.");
- }
- }
-
- private void createAvatar(JdbcTemplate template, String avatar) {
- if (template.queryForInt("select count(*) from system_avatar where name = ?", new Object[]{avatar}) == 0) {
-
- InputStream in = null;
- try {
- in = getClass().getResourceAsStream(avatar + ".png");
- byte[] imageData = IOUtils.toByteArray(in);
- template.update("insert into system_avatar values (null, ?, ?, ?, ?, ?, ?)",
- new Object[]{avatar, new Date(), "image/png", 48, 48, imageData});
- LOG.info("Created avatar '" + avatar + "'.");
- } catch (IOException x) {
- LOG.error("Failed to create avatar '" + avatar + "'.", x);
- } finally {
- IOUtils.closeQuietly(in);
- }
- }
- }
-} \ No newline at end of file
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema36.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema36.java
deleted file mode 100644
index caed6cdb..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema36.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.Logger;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implementes the database schema for Subsonic version 3.6.
- *
- * @author Sindre Mehus
- */
-public class Schema36 extends Schema {
-
- private static final Logger LOG = Logger.getLogger(Schema36.class);
-
- @Override
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 12") == 0) {
- LOG.info("Updating database schema to version 12.");
- template.execute("insert into version values (12)");
- }
-
- if (!columnExists(template, "technology", "player")) {
- LOG.info("Database column 'player.technology' not found. Creating it.");
- template.execute("alter table player add technology varchar default 'WEB' not null");
- LOG.info("Database column 'player.technology' was added successfully.");
- }
- }
-} \ No newline at end of file
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema37.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema37.java
deleted file mode 100644
index afb8fb6e..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema37.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.Logger;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implements the database schema for Subsonic version 3.7.
- *
- * @author Sindre Mehus
- */
-public class Schema37 extends Schema {
-
- private static final Logger LOG = Logger.getLogger(Schema37.class);
-
- @Override
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 13") == 0) {
- LOG.info("Updating database schema to version 13.");
- template.execute("insert into version values (13)");
- }
-
- if (template.queryForInt("select count(*) from role where id = 9") == 0) {
- LOG.info("Role 'settings' not found in database. Creating it.");
- template.execute("insert into role values (9, 'settings')");
- template.execute("insert into user_role select distinct u.username, 9 from user u");
- LOG.info("Role 'settings' was created successfully.");
- }
-
- if (template.queryForInt("select count(*) from role where id = 10") == 0) {
- LOG.info("Role 'jukebox' not found in database. Creating it.");
- template.execute("insert into role values (10, 'jukebox')");
- template.execute("insert into user_role " +
- "select distinct u.username, 10 from user u, user_role ur " +
- "where u.username = ur.username and ur.role_id = 1");
- LOG.info("Role 'jukebox' was created successfully.");
- }
-
- if (!columnExists(template, "changed", "music_folder")) {
- LOG.info("Database column 'music_folder.changed' not found. Creating it.");
- template.execute("alter table music_folder add changed datetime default 0 not null");
- LOG.info("Database column 'music_folder.changed' was added successfully.");
- }
-
- if (!columnExists(template, "changed", "internet_radio")) {
- LOG.info("Database column 'internet_radio.changed' not found. Creating it.");
- template.execute("alter table internet_radio add changed datetime default 0 not null");
- LOG.info("Database column 'internet_radio.changed' was added successfully.");
- }
-
- if (!columnExists(template, "changed", "user_settings")) {
- LOG.info("Database column 'user_settings.changed' not found. Creating it.");
- template.execute("alter table user_settings add changed datetime default 0 not null");
- LOG.info("Database column 'user_settings.changed' was added successfully.");
- }
-
- }
-} \ No newline at end of file
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema38.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema38.java
deleted file mode 100644
index fac49511..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema38.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.Logger;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implements the database schema for Subsonic version 3.8.
- *
- * @author Sindre Mehus
- */
-public class Schema38 extends Schema {
-
- private static final Logger LOG = Logger.getLogger(Schema38.class);
-
- @Override
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 14") == 0) {
- LOG.info("Updating database schema to version 14.");
- template.execute("insert into version values (14)");
- }
-
- if (!columnExists(template, "client_id", "player")) {
- LOG.info("Database column 'player.client_id' not found. Creating it.");
- template.execute("alter table player add client_id varchar");
- LOG.info("Database column 'player.client_id' was added successfully.");
- }
-
- if (!columnExists(template, "show_chat", "user_settings")) {
- LOG.info("Database column 'user_settings.show_chat' not found. Creating it.");
- template.execute("alter table user_settings add show_chat boolean default true not null");
- LOG.info("Database column 'user_settings.show_chat' was added successfully.");
- }
- }
-} \ No newline at end of file
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema40.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema40.java
deleted file mode 100644
index e01d1ef0..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema40.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.Logger;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implements the database schema for Subsonic version 4.0.
- *
- * @author Sindre Mehus
- */
-public class Schema40 extends Schema {
-
- private static final Logger LOG = Logger.getLogger(Schema40.class);
-
- @Override
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 15") == 0) {
- LOG.info("Updating database schema to version 15.");
- template.execute("insert into version values (15)");
-
- // Reset stream byte count since they have been wrong in earlier releases.
- template.execute("update user set bytes_streamed = 0");
- LOG.info("Reset stream byte count statistics.");
- }
- }
-} \ No newline at end of file
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema43.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema43.java
deleted file mode 100644
index cba1572c..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema43.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import org.springframework.jdbc.core.JdbcTemplate;
-
-import net.sourceforge.subsonic.Logger;
-
-import java.util.Arrays;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implements the database schema for Subsonic version 4.3.
- *
- * @author Sindre Mehus
- */
-public class Schema43 extends Schema {
-
- private static final Logger LOG = Logger.getLogger(Schema43.class);
-
- @Override
- public void execute(JdbcTemplate template) {
-
- // version 16 was used for 4.3.beta1
- if (template.queryForInt("select count(*) from version where version = 16") == 0) {
- LOG.info("Updating database schema to version 16.");
- template.execute("insert into version values (16)");
- }
-
- if (template.queryForInt("select count(*) from version where version = 17") == 0) {
- LOG.info("Updating database schema to version 17.");
- template.execute("insert into version values (17)");
-
- for (String format : Arrays.asList("avi", "mpg", "mpeg", "mp4", "m4v", "mkv", "mov", "wmv", "ogv")) {
- template.update("delete from transcoding where source_format=? and target_format=?", new Object[] {format, "flv"});
- template.execute("insert into transcoding values(null,'" + format + " > flv' ,'" + format + "' ,'flv','ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -',null,null,true,true)");
- template.execute("insert into player_transcoding select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = '" + format + " > flv'");
- }
- LOG.info("Created video transcoding configuration.");
- }
-
- if (!columnExists(template, "email", "user")) {
- LOG.info("Database column 'user.email' not found. Creating it.");
- template.execute("alter table user add email varchar");
- LOG.info("Database column 'user.email' was added successfully.");
- }
-
- }
-} \ No newline at end of file
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema45.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema45.java
deleted file mode 100644
index d82f2a92..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema45.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.Logger;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implements the database schema for Subsonic version 4.5.
- *
- * @author Sindre Mehus
- */
-public class Schema45 extends Schema {
-
- private static final Logger LOG = Logger.getLogger(Schema45.class);
-
- @Override
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 18") == 0) {
- LOG.info("Updating database schema to version 18.");
- template.execute("insert into version values (18)");
- }
-
- if (template.queryForInt("select count(*) from role where id = 11") == 0) {
- LOG.info("Role 'share' not found in database. Creating it.");
- template.execute("insert into role values (11, 'share')");
- template.execute("insert into user_role " +
- "select distinct u.username, 11 from user u, user_role ur " +
- "where u.username = ur.username and ur.role_id = 1");
- LOG.info("Role 'share' was created successfully.");
- }
-
- if (!tableExists(template, "share")) {
- LOG.info("Table 'share' not found in database. Creating it.");
- template.execute("create cached table share (" +
- "id identity," +
- "name varchar not null," +
- "description varchar," +
- "username varchar not null," +
- "created datetime not null," +
- "expires datetime," +
- "last_visited datetime," +
- "visit_count int default 0 not null," +
- "unique (name)," +
- "foreign key (username) references user(username) on delete cascade)");
- template.execute("create index idx_share_name on share(name)");
-
- LOG.info("Table 'share' was created successfully.");
- LOG.info("Table 'share_file' not found in database. Creating it.");
- template.execute("create cached table share_file (" +
- "id identity," +
- "share_id int not null," +
- "path varchar not null," +
- "foreign key (share_id) references share(id) on delete cascade)");
- LOG.info("Table 'share_file' was created successfully.");
- }
- }
-} \ No newline at end of file
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema46.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema46.java
deleted file mode 100644
index c1fcf357..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema46.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import org.springframework.jdbc.core.JdbcTemplate;
-
-import net.sourceforge.subsonic.Logger;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implements the database schema for Subsonic version 4.6.
- *
- * @author Sindre Mehus
- */
-public class Schema46 extends Schema {
-
- private static final Logger LOG = Logger.getLogger(Schema46.class);
-
- @Override
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 19") == 0) {
- LOG.info("Updating database schema to version 19.");
- template.execute("insert into version values (19)");
- }
-
- if (!tableExists(template, "transcoding2")) {
- LOG.info("Database table 'transcoding2' not found. Creating it.");
- template.execute("create table transcoding2 (" +
- "id identity," +
- "name varchar not null," +
- "source_formats varchar not null," +
- "target_format varchar not null," +
- "step1 varchar not null," +
- "step2 varchar," +
- "step3 varchar)");
-
- template.execute("insert into transcoding2 values(null,'mp3 audio'," +
- "'ogg oga aac m4a flac wav wma aif aiff ape mpc shn', 'mp3', " +
- "'ffmpeg -i %s -ab %bk -v 0 -f mp3 -', null, null)");
-
- template.execute("insert into transcoding2 values(null,'flv/h264 video', " +
- "'avi mpg mpeg mp4 m4v mkv mov wmv ogv divx m2ts', 'flv', " +
- "'ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -vcodec libx264 -preset superfast -threads 0 -', null, null)");
-
- LOG.info("Database table 'transcoding2' was created successfully.");
- }
-
- if (!tableExists(template, "player_transcoding2")) {
- LOG.info("Database table 'player_transcoding2' not found. Creating it.");
- template.execute("create table player_transcoding2 (" +
- "player_id int not null," +
- "transcoding_id int not null," +
- "primary key (player_id, transcoding_id)," +
- "foreign key (player_id) references player(id) on delete cascade," +
- "foreign key (transcoding_id) references transcoding2(id) on delete cascade)");
-
- template.execute("insert into player_transcoding2(player_id, transcoding_id) " +
- "select distinct p.id, t.id from player p, transcoding2 t");
-
- LOG.info("Database table 'player_transcoding2' was created successfully.");
- }
-
- if (!columnExists(template, "default_active", "transcoding2")) {
- LOG.info("Database column 'transcoding2.default_active' not found. Creating it.");
- template.execute("alter table transcoding2 add default_active boolean default true not null");
- LOG.info("Database column 'transcoding2.default_active' was added successfully.");
- }
- }
-
-} \ No newline at end of file
diff --git a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema47.java b/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema47.java
deleted file mode 100644
index 8b290b47..00000000
--- a/subsonic-main/src/main/java/net/sourceforge/subsonic/dao/schema/Schema47.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- This file is part of Subsonic.
-
- Subsonic is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Subsonic is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2009 (C) Sindre Mehus
- */
-package net.sourceforge.subsonic.dao.schema;
-
-import net.sourceforge.subsonic.Logger;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-/**
- * Used for creating and evolving the database schema.
- * This class implements the database schema for Subsonic version 4.7.
- *
- * @author Sindre Mehus
- */
-public class Schema47 extends Schema {
-
- private static final Logger LOG = Logger.getLogger(Schema47.class);
-
- @Override
- public void execute(JdbcTemplate template) {
-
- if (template.queryForInt("select count(*) from version where version = 20") == 0) {
- LOG.info("Updating database schema to version 20.");
- template.execute("insert into version values (20)");
- }
-
- if (!tableExists(template, "media_file")) {
- LOG.info("Database table 'media_file' not found. Creating it.");
- template.execute("create cached table media_file (" +
- "id identity," +
- "path varchar not null," +
- "folder varchar," +
- "type varchar not null," +
- "format varchar," +
- "title varchar," +
- "album varchar," +
- "artist varchar," +
- "album_artist varchar," +
- "disc_number int," +
- "track_number int," +
- "year int," +
- "genre varchar," +
- "bit_rate int," +
- "variable_bit_rate boolean not null," +
- "duration_seconds int," +
- "file_size bigint," +
- "width int," +
- "height int," +
- "cover_art_path varchar," +
- "parent_path varchar," +
- "play_count int not null," +
- "last_played datetime," +
- "comment varchar," +
- "created datetime not null," +
- "changed datetime not null," +
- "last_scanned datetime not null," +
- "children_last_updated datetime not null," +
- "present boolean not null," +
- "version int not null," +
- "unique (path))");
-
- template.execute("create index idx_media_file_path on media_file(path)");
- template.execute("create index idx_media_file_parent_path on media_file(parent_path)");
- template.execute("create index idx_media_file_type on media_file(type)");
- template.execute("create index idx_media_file_album on media_file(album)");
- template.execute("create index idx_media_file_artist on media_file(artist)");
- template.execute("create index idx_media_file_album_artist on media_file(album_artist)");
- template.execute("create index idx_media_file_present on media_file(present)");
- template.execute("create index idx_media_file_genre on media_file(genre)");
- template.execute("create index idx_media_file_play_count on media_file(play_count)");
- template.execute("create index idx_media_file_created on media_file(created)");
- template.execute("create index idx_media_file_last_played on media_file(last_played)");
-
- LOG.info("Database table 'media_file' was created successfully.");
- }
-
- if (!tableExists(template, "artist")) {
- LOG.info("Database table 'artist' not found. Creating it.");
- template.execute("create cached table artist (" +
- "id identity," +
- "name varchar not null," +
- "cover_art_path varchar," +
- "album_count int default 0 not null," +
- "last_scanned datetime not null," +
- "present boolean not null," +
- "unique (name))");
-
- template.execute("create index idx_artist_name on artist(name)");
- template.execute("create index idx_artist_present on artist(present)");
-
- LOG.info("Database table 'artist' was created successfully.");
- }
-
- if (!tableExists(template, "album")) {
- LOG.info("Database table 'album' not found. Creating it.");
- template.execute("create cached table album (" +
- "id identity," +
- "path varchar not null," +
- "name varchar not null," +
- "artist varchar not null," +
- "song_count int default 0 not null," +
- "duration_seconds int default 0 not null," +
- "cover_art_path varchar," +
- "play_count int default 0 not null," +
- "last_played datetime," +
- "comment varchar," +
- "created datetime not null," +
- "last_scanned datetime not null," +
- "present boolean not null," +
- "unique (artist, name))");
-
- template.execute("create index idx_album_artist_name on album(artist, name)");
- template.execute("create index idx_album_play_count on album(play_count)");
- template.execute("create index idx_album_last_played on album(last_played)");
- template.execute("create index idx_album_present on album(present)");
-
- LOG.info("Database table 'album' was created successfully.");
- }
-
- if (!tableExists(template, "starred_media_file")) {
- LOG.info("Database table 'starred_media_file' not found. Creating it.");
- template.execute("create table starred_media_file (" +
- "id identity," +
- "media_file_id int not null," +
- "username varchar not null," +
- "created datetime not null," +
- "foreign key (media_file_id) references media_file(id) on delete cascade,"+
- "foreign key (username) references user(username) on delete cascade," +
- "unique (media_file_id, username))");
-
- template.execute("create index idx_starred_media_file_media_file_id on starred_media_file(media_file_id)");
- template.execute("create index idx_starred_media_file_username on starred_media_file(username)");
-
- LOG.info("Database table 'starred_media_file' was created successfully.");
- }
-
- if (!tableExists(template, "starred_album")) {
- LOG.info("Database table 'starred_album' not found. Creating it.");
- template.execute("create table starred_album (" +
- "id identity," +
- "album_id int not null," +
- "username varchar not null," +
- "created datetime not null," +
- "foreign key (album_id) references album(id) on delete cascade," +
- "foreign key (username) references user(username) on delete cascade," +
- "unique (album_id, username))");
-
- template.execute("create index idx_starred_album_album_id on starred_album(album_id)");
- template.execute("create index idx_starred_album_username on starred_album(username)");
-
- LOG.info("Database table 'starred_album' was created successfully.");
- }
-
- if (!tableExists(template, "starred_artist")) {
- LOG.info("Database table 'starred_artist' not found. Creating it.");
- template.execute("create table starred_artist (" +
- "id identity," +
- "artist_id int not null," +
- "username varchar not null," +
- "created datetime not null," +
- "foreign key (artist_id) references artist(id) on delete cascade,"+
- "foreign key (username) references user(username) on delete cascade," +
- "unique (artist_id, username))");
-
- template.execute("create index idx_starred_artist_artist_id on starred_artist(artist_id)");
- template.execute("create index idx_starred_artist_username on starred_artist(username)");
-
- LOG.info("Database table 'starred_artist' was created successfully.");
- }
-
- if (!tableExists(template, "playlist")) {
- LOG.info("Database table 'playlist' not found. Creating it.");
- template.execute("create table playlist (" +
- "id identity," +
- "username varchar not null," +
- "is_public boolean not null," +
- "name varchar not null," +
- "comment varchar," +
- "file_count int default 0 not null," +
- "duration_seconds int default 0 not null," +
- "created datetime not null," +
- "changed datetime not null," +
- "foreign key (username) references user(username) on delete cascade)");
-
- LOG.info("Database table 'playlist' was created successfully.");
- }
-
- if (!columnExists(template, "imported_from", "playlist")) {
- LOG.info("Database column 'playlist.imported_from' not found. Creating it.");
- template.execute("alter table playlist add imported_from varchar");
- LOG.info("Database column 'playlist.imported_from' was added successfully.");
- }
-
- if (!tableExists(template, "playlist_file")) {
- LOG.info("Database table 'playlist_file' not found. Creating it.");
- template.execute("create cached table playlist_file (" +
- "id identity," +
- "playlist_id int not null," +
- "media_file_id int not null," +
- "foreign key (playlist_id) references playlist(id) on delete cascade," +
- "foreign key (media_file_id) references media_file(id) on delete cascade)");
-
- LOG.info("Database table 'playlist_file' was created successfully.");
- }
-
- if (!tableExists(template, "playlist_user")) {
- LOG.info("Database table 'playlist_user' not found. Creating it.");
- template.execute("create table playlist_user (" +
- "id identity," +
- "playlist_id int not null," +
- "username varchar not null," +
- "unique(playlist_id, username)," +
- "foreign key (playlist_id) references playlist(id) on delete cascade," +
- "foreign key (username) references user(username) on delete cascade)");
-
- LOG.info("Database table 'playlist_user' was created successfully.");
- }
- }
-} \ No newline at end of file