root/galaxy-central/lib/galaxy/model/migrate/versions/0029_user_actions.py

リビジョン 2, 1.3 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1"""
2This migration script adds a user actions table to Galaxy.
3"""
4
5from sqlalchemy import *
6from migrate import *
7
8import datetime
9now = datetime.datetime.utcnow
10
11import logging
12log = logging.getLogger( __name__ )
13
14metadata = MetaData( migrate_engine )
15
16def display_migration_details():
17    print ""
18    print "This migration script adds a user actions table to Galaxy."
19    print ""
20
21
22# New table to store user actions.
23UserAction_table = Table( "user_action", metadata,
24    Column( "id", Integer, primary_key=True ),
25    Column( "create_time", DateTime, default=now ),
26    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ),
27    Column( "session_id", Integer, ForeignKey( "galaxy_session.id" ), index=True ),
28    Column( "action", Unicode( 255 ) ),
29    Column( "context", Unicode( 512 ) ),
30    Column( "params", Unicode( 1024 ) ) )
31
32def upgrade():
33    display_migration_details()
34    metadata.reflect()
35    try:
36        UserAction_table.create()
37    except Exception, e:
38        print str(e)
39        log.debug( "Creating user_action table failed: %s" % str( e ) )
40
41def downgrade():
42    metadata.reflect()
43    try:
44        UserAction_table.drop()
45    except Exception, e:
46        print str(e)
47        log.debug( "Dropping user_action table failed: %s" % str( e ) )
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。