Ejemplo n.º 1
0
def downgrade(migrate_engine):
    metadata.bind = migrate_engine
    metadata.reflect()

    # TODO: Dropping a column used in a foreign key fails in MySQL, need to remove the FK first.
    for ix, table, col in indexes:
        drop_index(ix, table, col, metadata)
Ejemplo n.º 2
0
def downgrade(migrate_engine):
    metadata.bind = migrate_engine
    metadata.reflect()

    drop_index('ix_hda_ta_history_dataset_association_id',
               'history_dataset_association_tag_association',
               'history_dataset_association_id', metadata)
def downgrade(migrate_engine):
    metadata.bind = migrate_engine
    metadata.reflect()

    if migrate_engine.name == 'mysql':
        drop_index('ix_hdadaa_history_dataset_association_id',
                   'history_dataset_association_display_at_authorization',
                   'history_dataset_association_id', metadata)
Ejemplo n.º 4
0
def downgrade(migrate_engine):
    metadata.bind = migrate_engine
    metadata.reflect()

    # Drop the ix_dataset_state index
    drop_index('ix_dataset_state', 'dataset', 'state', metadata)

    # Drop the library_folder_id column
    drop_column('library_folder_id', 'job', metadata)

    # Drop the job_to_output_library_dataset table
    drop_table(JobToOutputLibraryDataset_table)
Ejemplo n.º 5
0
def upgrade(migrate_engine):
    print(__doc__)
    metadata.bind = migrate_engine
    metadata.reflect()

    Page_table = Table("page", metadata, autoload=True)
    try:
        # Sqlite doesn't support .alter, so we need to drop an recreate
        drop_index("ix_page_slug", Page_table, 'slug')

        add_index("ix_page_slug", Page_table, 'slug', unique=False)
    except Exception:
        # Mysql doesn't have a named index, but alter should work
        Page_table.c.slug.alter(unique=False)
Ejemplo n.º 6
0
def upgrade(migrate_engine):
    print(__doc__)
    metadata.bind = migrate_engine
    metadata.reflect()

    OldWorkflowStepConnection_table = Table("workflow_step_connection", metadata, autoload=True)
    for fkc in OldWorkflowStepConnection_table.foreign_key_constraints:
        mfkc = MigrateForeignKeyConstraint([_.parent for _ in fkc.elements], [_.column for _ in fkc.elements], name=fkc.name)
        try:
            mfkc.drop()
        except Exception:
            log.exception("Dropping foreign key constraint '%s' from table '%s' failed", mfkc.name, OldWorkflowStepConnection_table)

    for index in OldWorkflowStepConnection_table.indexes:
        drop_index(index, OldWorkflowStepConnection_table)
    OldWorkflowStepConnection_table.rename("workflow_step_connection_preupgrade145")
    # Try to deregister that table to work around some caching problems it seems.
    OldWorkflowStepConnection_table.deregister()
    metadata._remove_table("workflow_step_connection", metadata.schema)
    metadata.reflect()

    NewWorkflowStepConnection_table = Table(
        "workflow_step_connection", metadata,
        Column("id", Integer, primary_key=True),
        Column("output_step_id", Integer, ForeignKey("workflow_step.id"), index=True),
        Column("input_step_input_id", Integer, ForeignKey("workflow_step_input.id"), index=True),
        Column("output_name", TEXT),
        Column("input_subworkflow_step_id", Integer, ForeignKey("workflow_step.id"), index=True),
    )
    for table in (WorkflowStepInput_table, NewWorkflowStepConnection_table):
        create_table(table)

    insert_step_inputs_cmd = \
        "INSERT INTO workflow_step_input (workflow_step_id, name) " + \
        "SELECT DISTINCT input_step_id, input_name FROM workflow_step_connection_preupgrade145"
    migrate_engine.execute(insert_step_inputs_cmd)

    insert_step_connections_cmd = \
        "INSERT INTO workflow_step_connection (output_step_id, input_step_input_id, output_name, input_subworkflow_step_id) " + \
        "SELECT wsc.output_step_id, wsi.id, wsc.output_name, wsc.input_subworkflow_step_id " + \
        "FROM workflow_step_connection_preupgrade145 AS wsc JOIN workflow_step_input AS wsi ON wsc.input_step_id = wsi.workflow_step_id AND wsc.input_name = wsi.name ORDER BY wsc.id"
    migrate_engine.execute(insert_step_connections_cmd)
    drop_table(OldWorkflowStepConnection_table)
Ejemplo n.º 7
0
def downgrade(migrate_engine):
    metadata.bind = migrate_engine
    metadata.reflect()

    drop_index('ix_library_dataset_name', 'library_dataset', 'name', metadata)
    drop_index('ix_library_dataset_dataset_association_name', 'library_dataset_dataset_association', 'name', metadata)
    drop_index('ix_library_folder_name', 'library_folder', 'name', metadata)
def downgrade(migrate_engine):
    metadata.bind = migrate_engine
    metadata.reflect()

    # NOTE: all new data added in the upgrade method is eliminated here via table drops
    # Drop 1 foreign key constraint from the metadata_file table
    try:
        MetadataFile_table = Table("metadata_file", metadata, autoload=True)
    except NoSuchTableError:
        MetadataFile_table = None
        log.debug("Failed loading table metadata_file")
    try:
        LibraryDatasetDatasetAssociation_table = Table(
            "library_dataset_dataset_association", metadata, autoload=True)
    except NoSuchTableError:
        LibraryDatasetDatasetAssociation_table = None
        log.debug("Failed loading table library_dataset_dataset_association")
    if MetadataFile_table is not None and LibraryDatasetDatasetAssociation_table is not None:
        try:
            cons = ForeignKeyConstraint(
                [MetadataFile_table.c.lda_id],
                [LibraryDatasetDatasetAssociation_table.c.id],
                name='metadata_file_lda_id_fkey')
            # Drop the constraint
            cons.drop()
        except Exception:
            log.exception(
                "Dropping foreign key constraint 'metadata_file_lda_id_fkey' from table 'metadata_file' failed."
            )
    # Drop 1 foreign key constraint from the history_dataset_association table
    try:
        HistoryDatasetAssociation_table = Table("history_dataset_association",
                                                metadata,
                                                autoload=True)
    except NoSuchTableError:
        HistoryDatasetAssociation_table = None
        log.debug("Failed loading table history_dataset_association")
    try:
        LibraryDatasetDatasetAssociation_table = Table(
            "library_dataset_dataset_association", metadata, autoload=True)
    except NoSuchTableError:
        LibraryDatasetDatasetAssociation_table = None
        log.debug("Failed loading table library_dataset_dataset_association")
    if HistoryDatasetAssociation_table is not None and LibraryDatasetDatasetAssociation_table is not None:
        try:
            cons = ForeignKeyConstraint(
                [
                    HistoryDatasetAssociation_table.c.
                    copied_from_library_dataset_dataset_association_id
                ], [LibraryDatasetDatasetAssociation_table.c.id],
                name=
                'history_dataset_association_copied_from_library_dataset_da_fkey'
            )
            # Drop the constraint
            cons.drop()
        except Exception:
            log.exception(
                "Dropping foreign key constraint 'history_dataset_association_copied_from_library_dataset_da_fkey' from table 'history_dataset_association' failed."
            )
    # Drop all of the new tables above
    try:
        UserGroupAssociation_table.drop()
    except Exception:
        log.exception("Dropping user_group_association table failed.")
    try:
        UserRoleAssociation_table.drop()
    except Exception:
        log.exception("Dropping user_role_association table failed.")
    try:
        GroupRoleAssociation_table.drop()
    except Exception:
        log.exception("Dropping group_role_association table failed.")
    try:
        Group_table.drop()
    except Exception:
        log.exception("Dropping galaxy_group table failed.")
    try:
        DatasetPermissions_table.drop()
    except Exception:
        log.exception("Dropping dataset_permissions table failed.")
    try:
        LibraryPermissions_table.drop()
    except Exception:
        log.exception("Dropping library_permissions table failed.")
    try:
        LibraryFolderPermissions_table.drop()
    except Exception:
        log.exception("Dropping library_folder_permissions table failed.")
    try:
        LibraryDatasetPermissions_table.drop()
    except Exception:
        log.exception("Dropping library_dataset_permissions table failed.")
    try:
        LibraryDatasetDatasetAssociationPermissions_table.drop()
    except Exception:
        log.exception(
            "Dropping library_dataset_dataset_association_permissions table failed."
        )
    try:
        LibraryItemInfoPermissions_table.drop()
    except Exception:
        log.exception("Dropping library_item_info_permissions table failed.")
    try:
        LibraryItemInfoTemplatePermissions_table.drop()
    except Exception:
        log.exception(
            "Dropping library_item_info_template_permissions table failed.")
    try:
        DefaultUserPermissions_table.drop()
    except Exception:
        log.exception("Dropping default_user_permissions table failed.")
    try:
        DefaultHistoryPermissions_table.drop()
    except Exception:
        log.exception("Dropping default_history_permissions table failed.")
    try:
        Role_table.drop()
    except Exception:
        log.exception("Dropping role table failed.")
    try:
        LibraryDatasetDatasetInfoAssociation_table.drop()
    except Exception:
        log.exception(
            "Dropping library_dataset_dataset_info_association table failed.")
    try:
        LibraryDataset_table.drop()
    except Exception:
        log.exception("Dropping library_dataset table failed.")
    try:
        LibraryDatasetDatasetAssociation_table.drop()
    except Exception:
        log.exception(
            "Dropping library_dataset_dataset_association table failed.")
    try:
        LibraryDatasetDatasetInfoTemplateAssociation_table.drop()
    except Exception:
        log.exception(
            "Dropping library_dataset_dataset_info_template_association table failed."
        )
    try:
        JobExternalOutputMetadata_table.drop()
    except Exception:
        log.exception("Dropping job_external_output_metadata table failed.")
    try:
        Library_table.drop()
    except Exception:
        log.exception("Dropping library table failed.")
    try:
        LibraryFolder_table.drop()
    except Exception:
        log.exception("Dropping library_folder table failed.")
    try:
        LibraryItemInfoTemplateElement_table.drop()
    except Exception:
        log.exception(
            "Dropping library_item_info_template_element table failed.")
    try:
        LibraryInfoTemplateAssociation_table.drop()
    except Exception:
        log.exception(
            "Dropping library_info_template_association table failed.")
    try:
        LibraryFolderInfoTemplateAssociation_table.drop()
    except Exception:
        log.exception(
            "Dropping library_folder_info_template_association table failed.")
    try:
        LibraryDatasetInfoTemplateAssociation_table.drop()
    except Exception:
        log.exception(
            "Dropping library_dataset_info_template_association table failed.")
    try:
        LibraryInfoAssociation_table.drop()
    except Exception:
        log.exception("Dropping library_info_association table failed.")
    try:
        LibraryFolderInfoAssociation_table.drop()
    except Exception:
        log.exception("Dropping library_folder_info_association table failed.")
    try:
        LibraryDatasetInfoAssociation_table.drop()
    except Exception:
        log.exception(
            "Dropping library_dataset_info_association table failed.")
    try:
        LibraryItemInfoElement_table.drop()
    except Exception:
        log.exception("Dropping library_item_info_element table failed.")
    try:
        LibraryItemInfo_table.drop()
    except Exception:
        log.exception("Dropping library_item_info table failed.")
    try:
        LibraryItemInfoTemplate_table.drop()
    except Exception:
        log.exception("Dropping library_item_info_template table failed.")
    # Drop the index on the Job.state column - changeset 2192
    drop_index('ix_job_state', 'job', 'state', metadata)
    # Drop 1 column from the stored_workflow table - changeset 2328
    try:
        StoredWorkflow_table = Table("stored_workflow",
                                     metadata,
                                     autoload=True)
    except NoSuchTableError:
        StoredWorkflow_table = None
        log.debug("Failed loading table stored_workflow")
    if StoredWorkflow_table is not None:
        try:
            col = StoredWorkflow_table.c.importable
            col.drop()
        except Exception:
            log.exception(
                "Dropping column 'importable' from stored_workflow table failed."
            )
    # Drop 1 column from the metadata_file table
    try:
        MetadataFile_table = Table("metadata_file", metadata, autoload=True)
    except NoSuchTableError:
        MetadataFile_table = None
        log.debug("Failed loading table metadata_file")
    if MetadataFile_table is not None:
        try:
            col = MetadataFile_table.c.lda_id
            col.drop()
        except Exception:
            log.exception(
                "Dropping column 'lda_id' from metadata_file table failed.")
    # Drop 1 column from the history_dataset_association table
    try:
        HistoryDatasetAssociation_table = Table("history_dataset_association",
                                                metadata,
                                                autoload=True)
    except NoSuchTableError:
        HistoryDatasetAssociation_table = None
        log.debug("Failed loading table history_dataset_association")
    if HistoryDatasetAssociation_table is not None:
        try:
            col = HistoryDatasetAssociation_table.c.copied_from_library_dataset_dataset_association_id
            col.drop()
        except Exception:
            log.exception(
                "Dropping column 'copied_from_library_dataset_dataset_association_id' from history_dataset_association table failed."
            )
    # Drop 2 columns from the galaxy_user table
    try:
        User_table = Table("galaxy_user", metadata, autoload=True)
    except NoSuchTableError:
        User_table = None
        log.debug("Failed loading table galaxy_user")
    if User_table is not None:
        try:
            col = User_table.c.deleted
            col.drop()
        except Exception:
            log.exception(
                "Dropping column 'deleted' from galaxy_user table failed.")
        try:
            col = User_table.c.purged
            col.drop()
        except Exception:
            log.exception(
                "Dropping column 'purged' from galaxy_user table failed.")
Ejemplo n.º 9
0
def downgrade(migrate_engine):
    metadata.bind = migrate_engine
    metadata.reflect()

    for ix, table, col in indexes:
        drop_index(ix, table, col, metadata)
Ejemplo n.º 10
0
def downgrade(migrate_engine):
    metadata.bind = migrate_engine
    metadata.reflect()
    drop_index('ix_job_job_runner_external_id', 'job',
               'job_runner_external_id', metadata)
Ejemplo n.º 11
0
def downgrade(migrate_engine):
    metadata.bind = migrate_engine
    metadata.reflect()

    # NOTE: all new data added in the upgrade method is eliminated here via table drops
    # Drop 1 foreign key constraint from the metadata_file table
    MetadataFile_table = Table("metadata_file", metadata, autoload=True)
    LibraryDatasetDatasetAssociation_table = Table(
        "library_dataset_dataset_association", metadata, autoload=True)
    try:
        cons = ForeignKeyConstraint(
            [MetadataFile_table.c.lda_id],
            [LibraryDatasetDatasetAssociation_table.c.id],
            name='metadata_file_lda_id_fkey')
        # Drop the constraint
        cons.drop()
    except Exception:
        log.exception(
            "Dropping foreign key constraint 'metadata_file_lda_id_fkey' from table 'metadata_file' failed."
        )
    # Drop 1 foreign key constraint from the history_dataset_association table
    HistoryDatasetAssociation_table = Table("history_dataset_association",
                                            metadata,
                                            autoload=True)
    LibraryDatasetDatasetAssociation_table = Table(
        "library_dataset_dataset_association", metadata, autoload=True)
    try:
        cons = ForeignKeyConstraint(
            [
                HistoryDatasetAssociation_table.c.
                copied_from_library_dataset_dataset_association_id
            ], [LibraryDatasetDatasetAssociation_table.c.id],
            name=
            'history_dataset_association_copied_from_library_dataset_da_fkey')
        # Drop the constraint
        cons.drop()
    except Exception:
        log.exception(
            "Dropping foreign key constraint 'history_dataset_association_copied_from_library_dataset_da_fkey' from table 'history_dataset_association' failed."
        )
    # Drop all of the new tables above
    TABLES = [
        UserGroupAssociation_table,
        UserRoleAssociation_table,
        GroupRoleAssociation_table,
        Group_table,
        DatasetPermissions_table,
        LibraryPermissions_table,
        LibraryFolderPermissions_table,
        LibraryDatasetPermissions_table,
        LibraryDatasetDatasetAssociationPermissions_table,
        LibraryItemInfoPermissions_table,
        LibraryItemInfoTemplatePermissions_table,
        DefaultUserPermissions_table,
        DefaultHistoryPermissions_table,
        Role_table,
        LibraryDatasetDatasetInfoAssociation_table,
        LibraryDataset_table,
        LibraryDatasetDatasetAssociation_table,
        LibraryDatasetDatasetInfoTemplateAssociation_table,
        JobExternalOutputMetadata_table,
        Library_table,
        LibraryFolder_table,
        LibraryItemInfoTemplateElement_table,
        LibraryInfoTemplateAssociation_table,
        LibraryFolderInfoTemplateAssociation_table,
        LibraryDatasetInfoTemplateAssociation_table,
        LibraryInfoAssociation_table,
        LibraryFolderInfoAssociation_table,
        LibraryDatasetInfoAssociation_table,
        LibraryItemInfoElement_table,
        LibraryItemInfo_table,
        LibraryItemInfoTemplate_table,
    ]
    for table in TABLES:
        drop_table(table)
    # Drop the index on the Job.state column - changeset 2192
    drop_index('ix_job_state', 'job', 'state', metadata)
    # Drop 1 column from the stored_workflow table - changeset 2328
    drop_column('importable', 'stored_workflow', metadata)
    # Drop 1 column from the metadata_file table
    drop_column('lda_id', 'metadata_file', metadata)
    # Drop 1 column from the history_dataset_association table
    drop_column('copied_from_library_dataset_dataset_association_id',
                HistoryDatasetAssociation_table)
    # Drop 2 columns from the galaxy_user table
    User_table = Table("galaxy_user", metadata, autoload=True)
    drop_column('deleted', User_table)
    drop_column('purged', User_table)