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.0140_add_dataset_version_to_job_to_input_dataset_association_table
"""
Add dataset_version column to job_to_input_dataset table
"""
from __future__ import print_function
import logging
from sqlalchemy import Column, Integer, MetaData, Table
log = logging.getLogger(__name__)
dataset_version_column = Column("dataset_version", Integer)
[docs]def upgrade(migrate_engine):
print(__doc__)
metadata = MetaData()
metadata.bind = migrate_engine
metadata.reflect()
# Add the version column to the job_to_input_dataset table
try:
job_to_input_dataset_table = Table("job_to_input_dataset", metadata, autoload=True)
dataset_version_column.create(job_to_input_dataset_table)
assert dataset_version_column is job_to_input_dataset_table.c.dataset_version
except Exception:
log.exception("Adding column 'dataset_history_id' to job_to_input_dataset table failed.")
[docs]def downgrade(migrate_engine):
metadata = MetaData()
metadata.bind = migrate_engine
metadata.reflect()
# Drop the job_to_input_dataset table's version column.
try:
job_to_input_dataset_table = Table("job_to_input_dataset", metadata, autoload=True)
dataset_version_column = job_to_input_dataset_table.c.dataset_version
dataset_version_column.drop()
except Exception:
log.exception("Dropping 'dataset_version' column from job_to_input_dataset table failed.")