1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/e86e9e97daf8/ changeset: e86e9e97daf8 user: smcmanus date: 2012-09-29 06:37:46 summary: This is the migration script for the Job and Task tables' exit_code column. affected #: 1 file diff -r f76eaed275e6999fbe0cb575f95647fb168ed37f -r e86e9e97daf8f4b682cfe1fe5c12c8a408fd9cc3 lib/galaxy/model/migrate/versions/0107_add_exit_code_to_job_and_task.py --- /dev/null +++ b/lib/galaxy/model/migrate/versions/0107_add_exit_code_to_job_and_task.py @@ -0,0 +1,70 @@ +""" +Add the exit_code column to the Job and Task tables. +""" + +from sqlalchemy import * +from sqlalchemy.orm import * +from migrate import * +from migrate.changeset import * + +import logging +log = logging.getLogger( __name__ ) + +# Need our custom types, but don't import anything else from model +from galaxy.model.custom_types import * + +metadata = MetaData( migrate_engine ) +db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) ) + +# There was a bug when only one column was used for both tables, +# so create separate columns. +exit_code_job_col = Column( "exit_code", Integer, nullable=True ) +exit_code_task_col = Column( "exit_code", Integer, nullable=True ) + +def display_migration_details(): + print "" + print "This migration script adds a 'handler' column to the Job table." + +def upgrade(): + print __doc__ + metadata.reflect() + + # Add the exit_code column to the Job table. + try: + job_table = Table( "job", metadata, autoload=True ) + exit_code_job_col.create( job_table ) + assert exit_code_job_col is job_table.c.exit_code + except Exception, e: + print str(e) + log.error( "Adding column 'exit_code' to job table failed: %s" % str( e ) ) + return + + # Add the exit_code column to the Task table. + try: + task_table = Table( "task", metadata, autoload=True ) + exit_code_task_col.create( task_table ) + assert exit_code_task_col is task_table.c.exit_code + except Exception, e: + print str(e) + log.error( "Adding column 'exit_code' to task table failed: %s" % str( e ) ) + return + +def downgrade(): + metadata.reflect() + + # Drop the Job table's exit_code column. + try: + job_table = Table( "job", metadata, autoload=True ) + exit_code_col = job_table.c.exit_code + exit_code_col.drop() + except Exception, e: + log.debug( "Dropping 'exit_code' column from job table failed: %s" % ( str( e ) ) ) + + # Drop the Job table's exit_code column. + try: + task_table = Table( "task", metadata, autoload=True ) + exit_code_col = task_table.c.exit_code + exit_code_col.drop() + except Exception, e: + log.debug( "Dropping 'exit_code' column from task table failed: %s" % ( str( e ) ) ) + 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.