PageRenderTime 25ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/galaxy/model/migrate/versions/0034_page_user_share_association.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 42 lines | 29 code | 8 blank | 5 comment | 0 complexity | 665d37058221700e475bb7f4871d5823 MD5 | raw file
 1"""
 2Migration script to create a table for page-user share association.
 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
15PageUserShareAssociation_table = Table( "page_user_share_association", metadata,
16    Column( "id", Integer, primary_key=True ),
17    Column( "page_id", Integer, ForeignKey( "page.id" ), index=True ),
18    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True )
19    )
20
21def upgrade(migrate_engine):
22    metadata.bind = migrate_engine
23    print __doc__
24    metadata.reflect()
25
26    # Create stored_workflow_tag_association table.
27    try:
28        PageUserShareAssociation_table.create()
29    except Exception, e:
30        print str(e)
31        log.debug( "Creating page_user_share_association table failed: %s" % str( e ) )
32
33def downgrade(migrate_engine):
34    metadata.bind = migrate_engine
35    metadata.reflect()
36
37    # Drop workflow_tag_association table.
38    try:
39        PageUserShareAssociation_table.drop()
40    except Exception, e:
41        print str(e)
42        log.debug( "Dropping page_user_share_association table failed: %s" % str( e ) )