Warning

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 galaxy.model.migrate.versions.0081_add_tool_version_to_hda_ldda

"""
Migration script to add a 'tool_version' column to the hda/ldda tables.
"""

import logging

from sqlalchemy import Column, MetaData, Table, TEXT

log = logging.getLogger(__name__)
metadata = MetaData()


[docs]def upgrade(migrate_engine): metadata.bind = migrate_engine print(__doc__) metadata.reflect() try: hda_table = Table("history_dataset_association", metadata, autoload=True) c = Column("tool_version", TEXT) c.create(hda_table) assert c is hda_table.c.tool_version ldda_table = Table("library_dataset_dataset_association", metadata, autoload=True) c = Column("tool_version", TEXT) c.create(ldda_table) assert c is ldda_table.c.tool_version except Exception: log.exception("Adding the tool_version column to the hda/ldda tables failed.")
[docs]def downgrade(migrate_engine): metadata.bind = migrate_engine metadata.reflect() try: hda_table = Table("history_dataset_association", metadata, autoload=True) hda_table.c.tool_version.drop() ldda_table = Table("library_dataset_dataset_association", metadata, autoload=True) ldda_table.c.tool_version.drop() except Exception: log.exception("Dropping the tool_version column from hda/ldda table failed.")