[hg] galaxy 2633: Migration script to handle mysql index error i...
details: http://www.bx.psu.edu/hg/galaxy/rev/b85cb0a65f46 changeset: 2633:b85cb0a65f46 user: jeremy goecks <jeremy.goecks@emory.edu> date: Fri Aug 28 13:13:18 2009 -0400 description: Migration script to handle mysql index error in previous migration script ( 0015_tagging.py ) 1 file(s) affected in this change: lib/galaxy/model/migrate/versions/0016_v0015_mysql_index_fix.py diffs (56 lines): diff -r 31150f0b216d -r b85cb0a65f46 lib/galaxy/model/migrate/versions/0016_v0015_mysql_index_fix.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/galaxy/model/migrate/versions/0016_v0015_mysql_index_fix.py Fri Aug 28 13:13:18 2009 -0400 @@ -0,0 +1,51 @@ +""" +This script fixes a problem introduced in 0015_tagging.py. MySQL has a name length +limit and thus the index "ix_hda_ta_history_dataset_association_id" has to be +manually created. +""" + +from sqlalchemy import * +from migrate import * + +import datetime +now = datetime.datetime.utcnow + +# Need our custom types, but don't import anything else from model +from galaxy.model.custom_types import * + +import logging +log = logging.getLogger( __name__ ) + +metadata = MetaData( migrate_engine ) + +def display_migration_details(): + print "" + print "This script fixes a problem introduced in 0015_tagging.py. MySQL has a" + print "name length limit and thus the index 'ix_hda_ta_history_dataset_association_id'" + print "has to be manually created." + +HistoryDatasetAssociationTagAssociation_table = Table( "history_dataset_association_tag_association", metadata, + Column( "history_dataset_association_id", Integer, ForeignKey( "history_dataset_association.id" ), index=True ), + Column( "tag_id", Integer, ForeignKey( "tag.id" ), index=True ), + Column( "user_tname", TrimmedString(255), index=True), + Column( "value", TrimmedString(255), index=True), + Column( "user_value", TrimmedString(255), index=True) ) + +def upgrade(): + display_migration_details() + metadata.reflect() + i = Index( "ix_hda_ta_history_dataset_association_id", HistoryDatasetAssociationTagAssociation_table.c.history_dataset_association_id ) + try: + i.create() + except Exception, e: + print str(e) + log.debug( "Adding index 'ix_hdata_history_dataset_association_id' to table 'history_dataset_association_tag_association' table failed: %s" % str( e ) ) + +def downgrade(): + metadata.reflect() + i = Index( "ix_hda_ta_history_dataset_association_id", HistoryDatasetAssociationTagAssociation_table.c.history_dataset_association_id ) + try: + i.drop() + except Exception, e: + print str(e) + log.debug( "Removing index 'ix_hdata_history_dataset_association_id' to table 'history_dataset_association_tag_association' table failed: %s" % str( e ) ) \ No newline at end of file
participants (1)
-
Greg Von Kuster