2014-03-10 01:18:05 -04:00
|
|
|
# Author: Tyler Fenby <tylerfenby@gmail.com>
|
|
|
|
# URL: http://code.google.com/p/sickbeard/
|
|
|
|
#
|
2014-05-23 08:37:22 -04:00
|
|
|
# This file is part of SickRage.
|
2014-03-10 01:18:05 -04:00
|
|
|
#
|
2014-05-23 08:37:22 -04:00
|
|
|
# SickRage is free software: you can redistribute it and/or modify
|
2014-03-10 01:18:05 -04: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-05-23 08:37:22 -04:00
|
|
|
# SickRage is distributed in the hope that it will be useful,
|
2014-03-10 01:18:05 -04: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-05-23 08:37:22 -04:00
|
|
|
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
from sickbeard import db
|
|
|
|
from sickbeard.common import Quality
|
|
|
|
|
|
|
|
|
|
|
|
# Add new migrations at the bottom of the list; subclass the previous migration.
|
|
|
|
class InitialSchema(db.SchemaUpgrade):
|
|
|
|
def test(self):
|
|
|
|
return self.hasTable('failed')
|
|
|
|
|
|
|
|
def execute(self):
|
|
|
|
queries = [
|
|
|
|
('CREATE TABLE failed (release TEXT);',),
|
|
|
|
('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:])
|
|
|
|
|
|
|
|
|
|
|
|
class SizeAndProvider(InitialSchema):
|
|
|
|
def test(self):
|
|
|
|
return self.hasColumn('failed', 'size') and self.hasColumn('failed', 'provider')
|
|
|
|
|
|
|
|
def execute(self):
|
|
|
|
self.addColumn('failed', 'size')
|
|
|
|
self.addColumn('failed', 'provider', 'TEXT', '')
|
|
|
|
|
|
|
|
|
|
|
|
class History(SizeAndProvider):
|
|
|
|
"""Snatch history that can't be modified by the user"""
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
def test(self):
|
|
|
|
return self.hasTable('history')
|
|
|
|
|
|
|
|
def execute(self):
|
|
|
|
self.connection.action('CREATE TABLE history (date NUMERIC, ' +
|
|
|
|
'size NUMERIC, release TEXT, provider TEXT);')
|
|
|
|
|
|
|
|
|
|
|
|
class HistoryStatus(History):
|
|
|
|
"""Store episode status before snatch to revert to if necessary"""
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
def test(self):
|
|
|
|
return self.hasColumn('history', 'old_status')
|
|
|
|
|
|
|
|
def execute(self):
|
|
|
|
self.addColumn('history', 'old_status', 'NUMERIC', Quality.NONE)
|
|
|
|
self.addColumn('history', 'showid', 'NUMERIC', '-1')
|
|
|
|
self.addColumn('history', 'season', 'NUMERIC', '-1')
|
|
|
|
self.addColumn('history', 'episode', 'NUMERIC', '-1')
|