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.0110_add_dataset_uuid

"""
Add UUID column to dataset table
"""

import logging

from sqlalchemy import Column, MetaData, Table

from galaxy.model.custom_types import UUIDType

log = logging.getLogger(__name__)
dataset_uuid_column = Column("uuid", UUIDType, nullable=True)


[docs]def upgrade(migrate_engine): print(__doc__) metadata = MetaData() metadata.bind = migrate_engine metadata.reflect() # Add the uuid colum to the dataset table try: dataset_table = Table("dataset", metadata, autoload=True) dataset_uuid_column.create(dataset_table) assert dataset_uuid_column is dataset_table.c.uuid except Exception: log.exception("Adding column 'uuid' to dataset table failed.")
[docs]def downgrade(migrate_engine): metadata = MetaData() metadata.bind = migrate_engine metadata.reflect() # Drop the dataset table's uuid column. try: dataset_table = Table("dataset", metadata, autoload=True) dataset_uuid = dataset_table.c.uuid dataset_uuid.drop() except Exception: log.exception("Dropping 'uuid' column from dataset table failed.")