PageRenderTime 15ms CodeModel.GetById 2ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/lib/galaxy/model/migrate/versions/0055_add_pja_assoc_for_jobs.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 39 lines | 28 code | 7 blank | 4 comment | 0 complexity | 9af6bfc6d769b213b770fd6c218b7d93 MD5 | raw file
 1"""
 2Migration script to add the post_job_action_association table.
 3"""
 4
 5from sqlalchemy import *
 6from migrate import *
 7from migrate.changeset import *
 8from galaxy.model.custom_types import *
 9
10import datetime
11now = datetime.datetime.utcnow
12
13import logging
14log = logging.getLogger( __name__ )
15
16metadata = MetaData()
17
18PostJobActionAssociation_table = Table("post_job_action_association", metadata,
19    Column("id", Integer, primary_key=True),
20    Column("post_job_action_id", Integer, ForeignKey("post_job_action.id"), index=True, nullable=False),
21    Column("job_id", Integer, ForeignKey("job.id"), index=True, nullable=False))
22
23def upgrade(migrate_engine):
24    metadata.bind = migrate_engine
25    print __doc__
26    metadata.reflect()
27    try:
28        PostJobActionAssociation_table.create()
29    except Exception, e:
30        log.debug( "Creating PostJobActionAssociation table failed: %s" % str( e ) )
31
32def downgrade(migrate_engine):
33    metadata.bind = migrate_engine
34    # Load existing tables
35    metadata.reflect()
36    try:
37        PostJobActionAssociation_table.drop()
38    except Exception, e:
39        log.debug( "Dropping PostJobActionAssociation table failed: %s" % str( e ) )