Refactoring database migrations to use Alembic
... | ... | @@ -42,7 +42,7 @@ simplejson==3.17.2 |
service_identity==18.1.0 | ||
knowit==0.2.4 | ||
sqlalchemy==1.3.18 | ||
sqlalchemy-migrate==0.13.0 | ||
alembic==1.4.2 | ||
mutagen==1.45.1 | ||
deluge-client==1.9.0 | ||
dirsync==2.2.5 | ||
... | ... |
# ############################################################################## | ||
# Author: echel0n <[email protected]> | ||
# URL: https://sickrage.ca/ | ||
# Git: https://git.sickrage.ca/SiCKRAGE/sickrage.git | ||
# - | ||
# This file is part of SiCKRAGE. | ||
# - | ||
# SiCKRAGE 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. | ||
# - | ||
# SiCKRAGE 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 SiCKRAGE. If not, see <http://www.gnu.org/licenses/>. | ||
# ############################################################################## | ||
from migrate.changeset.constraint import PrimaryKeyConstraint | ||
from sqlalchemy import MetaData, Table, String | ||
def upgrade(migrate_engine): | ||
meta = MetaData(bind=migrate_engine) | ||
last_search = Table('last_search', meta, autoload=True) | ||
with migrate_engine.begin() as conn: | ||
conn.execute(last_search.delete()) | ||
last_search.c.provider.alter(type=String(32)) | ||
primary_key = PrimaryKeyConstraint(last_search.c.provider) | ||
primary_key.create() | ||
last_search.c.id.drop() | ||
def downgrade(migrate_engine): | ||
pass |
# ############################################################################## | ||
# Author: echel0n <[email protected]> | ||
# URL: https://sickrage.ca/ | ||
# Git: https://git.sickrage.ca/SiCKRAGE/sickrage.git | ||
# - | ||
# This file is part of SiCKRAGE. | ||
# - | ||
# SiCKRAGE 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. | ||
# - | ||
# SiCKRAGE 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 SiCKRAGE. If not, see <http://www.gnu.org/licenses/>. | ||
# ############################################################################## | ||
from migrate.changeset.constraint import PrimaryKeyConstraint | ||
from sqlalchemy import MetaData, Table, String | ||
def upgrade(migrate_engine): | ||
meta = MetaData(bind=migrate_engine) | ||
providers = Table('providers', meta, autoload=True) | ||
if hasattr(providers.c, 'indexer_id'): | ||
providers.c.indexer_id.alter(name='series_id') | ||
def downgrade(migrate_engine): | ||
meta = MetaData(bind=migrate_engine) | ||
providers = Table('providers', meta, autoload=True) | ||
if hasattr(providers.c, 'series_id'): | ||
providers.c.series_id.alter(name='indexer_id') |
# ############################################################################## | ||
# Author: echel0n <[email protected]> | ||
# URL: https://sickrage.ca/ | ||
# Git: https://git.sickrage.ca/SiCKRAGE/sickrage.git | ||
# - | ||
# This file is part of SiCKRAGE. | ||
# - | ||
# SiCKRAGE 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. | ||
# - | ||
# SiCKRAGE 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 SiCKRAGE. If not, see <http://www.gnu.org/licenses/>. | ||
# ############################################################################## | ||
import json | ||
import os | ||
from json import JSONDecodeError | ||
from sqlalchemy import * | ||
import sickrage | ||
def upgrade(migrate_engine): | ||
pass | ||
def downgrade(migrate_engine): | ||
pass |
# ############################################################################## | ||
# Author: echel0n <[email protected]> | ||
# URL: https://sickrage.ca/ | ||
# Git: https://git.sickrage.ca/SiCKRAGE/sickrage.git | ||
# - | ||
# This file is part of SiCKRAGE. | ||
# - | ||
# SiCKRAGE 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. | ||
# - | ||
# SiCKRAGE 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 SiCKRAGE. If not, see <http://www.gnu.org/licenses/>. | ||
# ############################################################################## | ||
from sqlalchemy import * | ||
def upgrade(migrate_engine): | ||
meta = MetaData(bind=migrate_engine) | ||
oauth2_token = Table('oauth2_token', meta, autoload=True) | ||
if not hasattr(oauth2_token.c, 'session_state'): | ||
session_state = Column('session_state', Text, default='') | ||
session_state.create(oauth2_token) | ||
def downgrade(migrate_engine): | ||
meta = MetaData(bind=migrate_engine) | ||
oauth2_token = Table('oauth2_token', meta, autoload=True) | ||
if hasattr(oauth2_token.c, 'session_state'): | ||
oauth2_token.c.session_state.drop() |
# ############################################################################## | ||
# Author: echel0n <[email protected]> | ||
# URL: https://sickrage.ca/ | ||
# Git: https://git.sickrage.ca/SiCKRAGE/sickrage.git | ||
# - | ||
# This file is part of SiCKRAGE. | ||
# - | ||
# SiCKRAGE 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. | ||
# - | ||
# SiCKRAGE 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 SiCKRAGE. If not, see <http://www.gnu.org/licenses/>. | ||
# ############################################################################## | ||
from sqlalchemy import * | ||
def upgrade(migrate_engine): | ||
meta = MetaData(bind=migrate_engine) | ||
oauth2_token = Table('oauth2_token', meta, autoload=True) | ||
if not hasattr(oauth2_token.c, 'token_type'): | ||
token_type = Column('token_type', Text, default='bearer') | ||
token_type.create(oauth2_token) | ||
def downgrade(migrate_engine): | ||
meta = MetaData(bind=migrate_engine) | ||
oauth2_token = Table('oauth2_token', meta, autoload=True) | ||
if hasattr(oauth2_token.c, 'token_type'): | ||
oauth2_token.c.token_type.drop() |
# ############################################################################## | ||
# Author: echel0n <[email protected]> | ||
# URL: https://sickrage.ca/ | ||
# Git: https://git.sickrage.ca/SiCKRAGE/sickrage.git | ||
# - | ||
# This file is part of SiCKRAGE. | ||
# - | ||
# SiCKRAGE 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. | ||
# - | ||
# SiCKRAGE 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 SiCKRAGE. If not, see <http://www.gnu.org/licenses/>. | ||
# ############################################################################## | ||
from sqlalchemy import * | ||
def upgrade(migrate_engine): | ||
meta = MetaData(bind=migrate_engine) | ||
quicksearch_shows = Table('quicksearch_shows', meta, autoload=True) | ||
if quicksearch_shows is not None: | ||
quicksearch_shows.drop() | ||
quicksearch_episodes = Table('quicksearch_episodes', meta, autoload=True) | ||
if quicksearch_episodes is not None: | ||
quicksearch_episodes.drop() | ||
def downgrade(migrate_engine): | ||
pass |