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.0071_add_history_and_workflow_to_sample
"""
Migration script to add 'workflow' and 'history' columns for a sample.
"""
from __future__ import print_function
import logging
from sqlalchemy import Column, ForeignKey, Integer, MetaData, Table
from galaxy.model.custom_types import JSONType
from galaxy.model.migrate.versions.util import add_column, drop_column
log = logging.getLogger(__name__)
metadata = MetaData()
[docs]def upgrade(migrate_engine):
print(__doc__)
metadata.bind = migrate_engine
metadata.reflect()
Sample_table = Table("sample", metadata, autoload=True)
c1 = Column("workflow", JSONType, nullable=True)
add_column(c1, Sample_table, metadata)
c2 = Column("history_id", Integer, ForeignKey("history.id"), nullable=True)
add_column(c2, Sample_table, metadata)
[docs]def downgrade(migrate_engine):
metadata.bind = migrate_engine
metadata.reflect()
Sample_table = Table("sample", metadata, autoload=True)
drop_column('workflow', Sample_table)
drop_column('history_id', Sample_table)