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.0036_add_deleted_column_to_library_template_assoc_tables
"""
Migration script to add a deleted column to the following tables:
library_info_association, library_folder_info_association, library_dataset_dataset_info_association.
"""
import logging
from sqlalchemy import Boolean, Column, MetaData, Table
from galaxy.model.migrate.versions.util import engine_false
log = logging.getLogger(__name__)
metadata = MetaData()
[docs]def upgrade(migrate_engine):
print(__doc__)
metadata.bind = migrate_engine
metadata.reflect()
try:
LibraryInfoAssociation_table = Table("library_info_association", metadata, autoload=True)
c = Column("deleted", Boolean, index=True, default=False)
c.create(LibraryInfoAssociation_table, index_name='ix_library_info_association_deleted')
assert c is LibraryInfoAssociation_table.c.deleted
except Exception:
log.exception("Adding column 'deleted' to 'library_info_association' table failed.")
cmd = "UPDATE library_info_association SET deleted = %s" % engine_false(migrate_engine)
try:
migrate_engine.execute(cmd)
except Exception:
log.exception("deleted to false in library_info_association failed.")
try:
LibraryFolderInfoAssociation_table = Table("library_folder_info_association", metadata, autoload=True)
c = Column("deleted", Boolean, index=True, default=False)
c.create(LibraryFolderInfoAssociation_table, index_name='ix_library_folder_info_association_deleted')
assert c is LibraryFolderInfoAssociation_table.c.deleted
except Exception:
log.exception("Adding column 'deleted' to 'library_folder_info_association' table failed.")
cmd = "UPDATE library_folder_info_association SET deleted = %s" % engine_false(migrate_engine)
try:
migrate_engine.execute(cmd)
except Exception:
log.exception("deleted to false in library_folder_info_association failed.")
try:
LibraryDatasetDatasetInfoAssociation_table = Table("library_dataset_dataset_info_association", metadata, autoload=True)
c = Column("deleted", Boolean, index=True, default=False)
c.create(LibraryDatasetDatasetInfoAssociation_table, index_name='ix_library_dataset_dataset_info_association_deleted')
assert c is LibraryDatasetDatasetInfoAssociation_table.c.deleted
except Exception:
log.exception("Adding column 'deleted' to 'library_dataset_dataset_info_association' table failed.")
cmd = "UPDATE library_dataset_dataset_info_association SET deleted = %s" % engine_false(migrate_engine)
try:
migrate_engine.execute(cmd)
except Exception:
log.exception("deleted to false in library_dataset_dataset_info_association failed.")