| 1 | """ |
|---|
| 2 | This script fixes a problem introduced in 0015_tagging.py. MySQL has a name length |
|---|
| 3 | limit and thus the index "ix_hda_ta_history_dataset_association_id" has to be |
|---|
| 4 | manually created. |
|---|
| 5 | """ |
|---|
| 6 | |
|---|
| 7 | from sqlalchemy import * |
|---|
| 8 | from migrate import * |
|---|
| 9 | |
|---|
| 10 | import datetime |
|---|
| 11 | now = datetime.datetime.utcnow |
|---|
| 12 | |
|---|
| 13 | # Need our custom types, but don't import anything else from model |
|---|
| 14 | from galaxy.model.custom_types import * |
|---|
| 15 | |
|---|
| 16 | import logging |
|---|
| 17 | log = logging.getLogger( __name__ ) |
|---|
| 18 | |
|---|
| 19 | metadata = MetaData( migrate_engine ) |
|---|
| 20 | |
|---|
| 21 | def display_migration_details(): |
|---|
| 22 | print "" |
|---|
| 23 | print "This script fixes a problem introduced in 0015_tagging.py. MySQL has a" |
|---|
| 24 | print "name length limit and thus the index 'ix_hda_ta_history_dataset_association_id'" |
|---|
| 25 | print "has to be manually created." |
|---|
| 26 | |
|---|
| 27 | HistoryDatasetAssociationTagAssociation_table = Table( "history_dataset_association_tag_association", metadata, |
|---|
| 28 | Column( "history_dataset_association_id", Integer, ForeignKey( "history_dataset_association.id" ), index=True ), |
|---|
| 29 | Column( "tag_id", Integer, ForeignKey( "tag.id" ), index=True ), |
|---|
| 30 | Column( "user_tname", TrimmedString(255), index=True), |
|---|
| 31 | Column( "value", TrimmedString(255), index=True), |
|---|
| 32 | Column( "user_value", TrimmedString(255), index=True) ) |
|---|
| 33 | |
|---|
| 34 | def upgrade(): |
|---|
| 35 | display_migration_details() |
|---|
| 36 | metadata.reflect() |
|---|
| 37 | i = Index( "ix_hda_ta_history_dataset_association_id", HistoryDatasetAssociationTagAssociation_table.c.history_dataset_association_id ) |
|---|
| 38 | try: |
|---|
| 39 | i.create() |
|---|
| 40 | except Exception, e: |
|---|
| 41 | print str(e) |
|---|
| 42 | log.debug( "Adding index 'ix_hdata_history_dataset_association_id' to table 'history_dataset_association_tag_association' table failed: %s" % str( e ) ) |
|---|
| 43 | |
|---|
| 44 | def downgrade(): |
|---|
| 45 | metadata.reflect() |
|---|
| 46 | i = Index( "ix_hda_ta_history_dataset_association_id", HistoryDatasetAssociationTagAssociation_table.c.history_dataset_association_id ) |
|---|
| 47 | try: |
|---|
| 48 | i.drop() |
|---|
| 49 | except Exception, e: |
|---|
| 50 | print str(e) |
|---|
| 51 | log.debug( "Removing index 'ix_hdata_history_dataset_association_id' to table 'history_dataset_association_tag_association' table failed: %s" % str( e ) ) |
|---|