PageRenderTime 21ms CodeModel.GetById 8ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/galaxy/model/migrate/versions/0070_add_info_column_to_deferred_job_table.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 36 lines | 35 code | 0 blank | 1 comment | 0 complexity | 440201132ade1eb9f49fa51dfd8fa26d MD5 | raw file
 1"""
 2Migration script to add 'info' column to the transfer_job table.
 3"""
 4
 5from sqlalchemy import *
 6from sqlalchemy.orm import *
 7from migrate import *
 8from migrate.changeset import *
 9
10import logging
11log = logging.getLogger( __name__ )
12
13metadata = MetaData()
14
15def upgrade(migrate_engine):
16    metadata.bind = migrate_engine
17    print __doc__
18    metadata.reflect()
19    try:
20        TransferJob_table = Table( "transfer_job", metadata, autoload=True )
21        c = Column( "info", TEXT )
22        c.create( TransferJob_table )
23        assert c is TransferJob_table.c.info
24    except Exception, e:
25        print "Adding info column to transfer_job table failed: %s" % str( e )
26        log.debug( "Adding info column to transfer_job table failed: %s" % str( e ) )
27
28def downgrade(migrate_engine):
29    metadata.bind = migrate_engine
30    metadata.reflect()
31    try:
32        TransferJob_table = Table( "transfer_job", metadata, autoload=True )
33        TransferJob_table.c.info.drop()
34    except Exception, e:
35        print "Dropping info column from transfer_job table failed: %s" % str( e )
36        log.debug( "Dropping info column from transfer_job table failed: %s" % str( e ) )