This document is for an old release 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 tool_shed.webapp.model.migrate.versions.0014_add_deprecated_column

Migration script to add the deprecated column to the repository table.

import logging
import sys

from sqlalchemy import Boolean, Column, MetaData, Table

log = logging.getLogger(__name__)
handler = logging.StreamHandler(sys.stdout)
format = "%(name)s %(levelname)s %(asctime)s %(message)s"
formatter = logging.Formatter(format)

metadata = MetaData()

[docs]def upgrade(migrate_engine): print(__doc__) metadata.bind = migrate_engine metadata.reflect() # Create and initialize imported column in job table. Repository_table = Table("repository", metadata, autoload=True) c = Column("deprecated", Boolean, default=False) try: # Create c.create(Repository_table) assert c is Repository_table.c.deprecated # Initialize. if migrate_engine.name == 'mysql' or migrate_engine.name == 'sqlite': default_false = "0" elif migrate_engine.name in ['postgresql', 'postgres']: default_false = "false" migrate_engine.execute(f"UPDATE repository SET deprecated={default_false}") except Exception: log.exception("Adding deprecated column to the repository table failed.")
[docs]def downgrade(migrate_engine): metadata.bind = migrate_engine metadata.reflect() # Drop email_alerts column from repository table. Repository_table = Table("repository", metadata, autoload=True) try: Repository_table.c.deprecated.drop() except Exception: log.exception("Dropping column deprecated from the repository table failed.")