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.0137_add_copied_from_job_id_column
"""
Add copied_from_job_id column to jobs table
"""
from __future__ import print_function
import logging
from sqlalchemy import Column, Integer, MetaData, Table
log = logging.getLogger(__name__)
copied_from_job_id_column = Column("copied_from_job_id", Integer, nullable=True)
[docs]def upgrade(migrate_engine):
print(__doc__)
metadata = MetaData()
metadata.bind = migrate_engine
metadata.reflect()
# Add the copied_from_job_id column to the job table
try:
jobs_table = Table("job", metadata, autoload=True)
copied_from_job_id_column.create(jobs_table)
assert copied_from_job_id_column is jobs_table.c.copied_from_job_id
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 job table's copied_from_job_id column.
try:
jobs_table = Table("job", metadata, autoload=True)
copied_from_job_id = jobs_table.c.copied_from_job_id
copied_from_job_id.drop()
except Exception:
log.exception("Dropping 'copied_from_job_id_column' column from job table failed.")