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.0138_add_hda_version
"""
Add version column to history_dataset_association table
"""
import logging
from sqlalchemy import Column, Integer, MetaData, Table
log = logging.getLogger(__name__)
version_column = Column("version", Integer, default=1)
[docs]def upgrade(migrate_engine):
print(__doc__)
metadata = MetaData()
metadata.bind = migrate_engine
metadata.reflect()
# Add the version column to the history_dataset_association table
try:
hda_table = Table("history_dataset_association", metadata, autoload=True)
version_column.create(hda_table)
assert version_column is hda_table.c.version
except Exception:
log.exception("Adding column 'copied_from_job_id_column' to job table failed.")
[docs]def downgrade(migrate_engine):
metadata = MetaData()
metadata.bind = migrate_engine
metadata.reflect()
# Drop the history_dataset_association table's version column.
try:
hda_table = Table("history_dataset_association", metadata, autoload=True)
version_column = hda_table.c.version
version_column.drop()
except Exception:
log.exception("Dropping 'copied_from_job_id_column' column from job table failed.")