Warning
This document is for an old release 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.0048_dataset_instance_state_column
"""
Add a state column to the history_dataset_association and library_dataset_dataset_association table.
"""
import logging
from sqlalchemy import (
Column,
MetaData,
)
from galaxy.model.custom_types import TrimmedString
from galaxy.model.migrate.versions.util import (
add_column,
drop_column
)
log = logging.getLogger(__name__)
metadata = MetaData()
DATASET_INSTANCE_TABLE_NAMES = ['history_dataset_association', 'library_dataset_dataset_association']
[docs]def upgrade(migrate_engine):
print(__doc__)
metadata.bind = migrate_engine
metadata.reflect()
for table_name in DATASET_INSTANCE_TABLE_NAMES:
col = Column("state", TrimmedString(64), index=True, nullable=True)
index_name = f"ix_{table_name}_state"
add_column(col, table_name, metadata, index_name=index_name)
[docs]def downgrade(migrate_engine):
metadata.bind = migrate_engine
metadata.reflect()
for table_name in DATASET_INSTANCE_TABLE_NAMES:
drop_column('state', table_name, metadata)