commit/galaxy-central: greg: Migration script to alter the tool_dependency.version database table column type to Text.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/b762062399b3/ changeset: b762062399b3 user: greg date: 2012-06-12 21:09:39 summary: Migration script to alter the tool_dependency.version database table column type to Text. affected #: 2 files diff -r 9a3ab5009e8e70596a07283e3611661410f92c4d -r b762062399b3cab0a4139dc3fcd33f30945e49ac lib/galaxy/model/mapping.py --- a/lib/galaxy/model/mapping.py +++ b/lib/galaxy/model/mapping.py @@ -397,7 +397,7 @@ Column( "tool_shed_repository_id", Integer, ForeignKey( "tool_shed_repository.id" ), index=True, nullable=False ), Column( "installed_changeset_revision", TrimmedString( 255 ) ), Column( "name", TrimmedString( 255 ) ), - Column( "version", TrimmedString( 40 ) ), + Column( "version", Text ), Column( "type", TrimmedString( 40 ) ), Column( "uninstalled", Boolean, default=False ) ) diff -r 9a3ab5009e8e70596a07283e3611661410f92c4d -r b762062399b3cab0a4139dc3fcd33f30945e49ac lib/galaxy/model/migrate/versions/0100_alter_tool_dependency_table_version_column.py --- /dev/null +++ b/lib/galaxy/model/migrate/versions/0100_alter_tool_dependency_table_version_column.py @@ -0,0 +1,53 @@ +""" +Migration script to alter the type of the tool_dependency.version column from TrimmedString(40) to Text. +""" + +from sqlalchemy import * +from sqlalchemy.orm import * +from migrate import * +from migrate.changeset 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 sys, logging +log = logging.getLogger( __name__ ) +log.setLevel(logging.DEBUG) +handler = logging.StreamHandler( sys.stdout ) +format = "%(name)s %(levelname)s %(asctime)s %(message)s" +formatter = logging.Formatter( format ) +handler.setFormatter( formatter ) +log.addHandler( handler ) + +metadata = MetaData( migrate_engine ) +db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) ) + +def upgrade(): + print __doc__ + metadata.reflect() + ToolDependency_table = Table( "tool_dependency", metadata, autoload=True ) + # Change the tool_dependency table's version column from TrimmedString to Text. + if migrate_engine.name == 'postgres': + cmd = "ALTER TABLE tool_dependency ALTER COLUMN version TYPE Text;" + elif migrate_engine.name == 'mysql': + cmd = "ALTER TABLE tool_dependency MODIFY COLUMN version Text;" + else: + # We don't have to do anything for sqlite tables. From the sqlite documentation at http://sqlite.org/datatype3.html: + # 1.0 Storage Classes and Datatypes + # Each value stored in an SQLite database (or manipulated by the database engine) has one of the following storage classes: + # NULL. The value is a NULL value. + # INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value. + # REAL. The value is a floating point value, stored as an 8-byte IEEE floating point number. + # TEXT. The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE). + # BLOB. The value is a blob of data, stored exactly as it was input. + cmd = None + if cmd: + try: + db_session.execute( cmd ) + except Exception, e: + log.debug( "Altering tool_dependency.version column from TrimmedString(40) to Text failed: %s" % str( e ) ) +def downgrade(): + # Not necessary to change column type Text to TrimmedString(40). + pass Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket