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.0090_add_tool_shed_repository_table_columns

"""
Migration script to add the uninstalled and dist_to_shed columns to the tool_shed_repository table.
"""

import logging

from sqlalchemy import (
    Boolean,
    Column,
    MetaData,
    Table
)

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) c = Column("uninstalled", Boolean, default=False) add_column(c, ToolShedRepository_table, metadata) try: migrate_engine.execute("UPDATE tool_shed_repository SET uninstalled=%s" % engine_false(migrate_engine)) except Exception: log.exception("Updating column 'uninstalled' of table 'tool_shed_repository' failed.") c = Column("dist_to_shed", Boolean, default=False) add_column(c, ToolShedRepository_table, metadata) try: migrate_engine.execute("UPDATE tool_shed_repository SET dist_to_shed=%s" % engine_false(migrate_engine)) except Exception: log.exception("Updating column 'dist_to_shed' of table 'tool_shed_repository' failed.")
[docs]def downgrade(migrate_engine): 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('uninstalled', ToolShedRepository_table) drop_column('dist_to_shed', ToolShedRepository_table)