Warning
This document is for an in-development version of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.
Source code for galaxy.model.migrate.versions.0116_drop_update_available_col_add_tool_shed_status_col
"""
Migration script to drop the update_available Boolean column and replace it with the tool_shed_status JSONType column in the tool_shed_repository table.
"""
from __future__ import print_function
import logging
from sqlalchemy import (
Boolean,
Column,
MetaData,
Table
)
from galaxy.model.custom_types import JSONType
from galaxy.model.migrate.versions.util import (
add_column,
drop_column,
engine_false
)
log = logging.getLogger(__name__)
metadata = MetaData()
[docs]def upgrade(migrate_engine):
print(__doc__)
metadata.bind = migrate_engine
metadata.reflect()
ToolShedRepository_table = Table("tool_shed_repository", metadata, autoload=True)
# SQLAlchemy Migrate has a bug when dropping a boolean column in SQLite
if migrate_engine.name != 'sqlite':
drop_column('update_available', ToolShedRepository_table)
c = Column("tool_shed_status", JSONType, nullable=True)
add_column(c, ToolShedRepository_table, metadata)
[docs]def downgrade(migrate_engine):
metadata.bind = migrate_engine
metadata.reflect()
ToolShedRepository_table = Table("tool_shed_repository", metadata, autoload=True)
drop_column('tool_shed_status', ToolShedRepository_table)
c = Column("update_available", Boolean, default=False)
add_column(c, ToolShedRepository_table, metadata)
try:
migrate_engine.execute("UPDATE tool_shed_repository SET update_available=%s" % engine_false(migrate_engine))
except Exception:
log.exception("Updating column 'update_available' of table 'tool_shed_repository' failed.")