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.0093_add_job_params_col

"""
Migration script to add a 'params' column to the 'job' table.
"""

import logging

from sqlalchemy import Column, MetaData, Table

# Need our custom types, but don't import anything else from model
from galaxy.model.custom_types import TrimmedString

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

# Column to add.
params_col = Column("params", TrimmedString(255), index=True)


[docs]def upgrade(migrate_engine): metadata.bind = migrate_engine print(__doc__) metadata.reflect() # Add column to Job table. try: Job_table = Table("job", metadata, autoload=True) params_col.create(Job_table, index_name="ix_job_params") assert params_col is Job_table.c.params except Exception: log.exception("Adding column 'params' to job table failed.")
[docs]def downgrade(migrate_engine): metadata.bind = migrate_engine metadata.reflect() # Drop column from Job table. try: Job_table = Table("job", metadata, autoload=True) params_col = Job_table.c.params params_col.drop() except Exception: log.exception("Dropping column 'params' from job table failed.")