2014-03-10 05:18:05 +00:00
|
|
|
# Author: Nic Wolfe <nic@wolfeden.ca>
|
|
|
|
# URL: http://code.google.com/p/sickbeard/
|
|
|
|
#
|
2014-11-12 16:43:14 +00:00
|
|
|
# This file is part of SickGear.
|
2014-03-10 05:18:05 +00:00
|
|
|
#
|
2014-11-12 16:43:14 +00:00
|
|
|
# SickGear is free software: you can redistribute it and/or modify
|
2014-03-10 05:18:05 +00:00
|
|
|
# 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.
|
|
|
|
#
|
2014-11-12 16:43:14 +00:00
|
|
|
# SickGear is distributed in the hope that it will be useful,
|
2014-03-10 05:18:05 +00:00
|
|
|
# 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
|
2014-11-12 16:43:14 +00:00
|
|
|
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
from sickbeard import db
|
|
|
|
|
|
|
|
# Add new migrations at the bottom of the list; subclass the previous migration.
|
2014-03-25 05:57:24 +00:00
|
|
|
class InitialSchema(db.SchemaUpgrade):
|
2014-03-10 05:18:05 +00:00
|
|
|
def test(self):
|
|
|
|
return self.hasTable("lastUpdate")
|
|
|
|
|
|
|
|
def execute(self):
|
|
|
|
|
|
|
|
queries = [
|
|
|
|
("CREATE TABLE lastUpdate (provider TEXT, time NUMERIC);",),
|
2014-05-15 07:20:00 +00:00
|
|
|
("CREATE TABLE lastSearch (provider TEXT, time NUMERIC);",),
|
2014-03-10 05:18:05 +00:00
|
|
|
("CREATE TABLE db_version (db_version INTEGER);",),
|
|
|
|
("INSERT INTO db_version (db_version) VALUES (?)", 1),
|
|
|
|
]
|
|
|
|
for query in queries:
|
|
|
|
if len(query) == 1:
|
|
|
|
self.connection.action(query[0])
|
|
|
|
else:
|
|
|
|
self.connection.action(query[0], query[1:])
|
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
class AddSceneExceptions(InitialSchema):
|
|
|
|
def test(self):
|
|
|
|
return self.hasTable("scene_exceptions")
|
|
|
|
|
|
|
|
def execute(self):
|
2014-03-25 05:57:24 +00:00
|
|
|
self.connection.action(
|
2014-05-26 06:29:22 +00:00
|
|
|
"CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER KEY, show_name TEXT)")
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
class AddSceneNameCache(AddSceneExceptions):
|
|
|
|
def test(self):
|
|
|
|
return self.hasTable("scene_names")
|
|
|
|
|
|
|
|
def execute(self):
|
2014-05-26 06:29:22 +00:00
|
|
|
self.connection.action("CREATE TABLE scene_names (indexer_id INTEGER, name TEXT)")
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
class AddNetworkTimezones(AddSceneNameCache):
|
|
|
|
def test(self):
|
|
|
|
return self.hasTable("network_timezones")
|
|
|
|
|
|
|
|
def execute(self):
|
2014-03-11 16:35:13 +00:00
|
|
|
self.connection.action("CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT)")
|
|
|
|
|
2014-05-28 21:13:29 +00:00
|
|
|
class AddLastSearch(AddNetworkTimezones):
|
2014-03-11 16:35:13 +00:00
|
|
|
def test(self):
|
2014-05-26 06:29:22 +00:00
|
|
|
return self.hasTable("lastSearch")
|
2014-03-11 16:35:13 +00:00
|
|
|
|
|
|
|
def execute(self):
|
2014-05-26 06:29:22 +00:00
|
|
|
self.connection.action("CREATE TABLE lastSearch (provider TEXT, time NUMERIC)")
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-05-26 06:29:22 +00:00
|
|
|
class AddSceneExceptionsSeasons(AddSceneNameCache):
|
2014-05-15 07:20:00 +00:00
|
|
|
def test(self):
|
2014-05-26 06:29:22 +00:00
|
|
|
return self.hasColumn("scene_exceptions", "season")
|
2014-05-15 07:20:00 +00:00
|
|
|
|
|
|
|
def execute(self):
|
2014-05-30 12:30:28 +00:00
|
|
|
self.addColumn("scene_exceptions", "season", "NUMERIC", -1)
|
|
|
|
|
|
|
|
class AddSceneExceptionsCustom(AddSceneExceptionsSeasons):
|
|
|
|
def test(self):
|
|
|
|
return self.hasColumn("scene_exceptions", "custom")
|
|
|
|
|
|
|
|
def execute(self):
|
2014-06-01 06:44:44 +00:00
|
|
|
self.addColumn("scene_exceptions", "custom", "NUMERIC", 0)
|
|
|
|
|
|
|
|
class AddSceneExceptionsRefresh(AddSceneExceptionsCustom):
|
|
|
|
def test(self):
|
|
|
|
return self.hasTable("scene_exceptions_refresh")
|
|
|
|
|
|
|
|
def execute(self):
|
|
|
|
self.connection.action(
|
2014-12-07 13:19:45 +00:00
|
|
|
"CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER)")
|