root/galaxy-central/lib/galaxy/model/migrate/versions/0021_user_prefs.py

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

import galaxy-central

行番号 
1"""
2This migration script adds a user preferences 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 preferences table to Galaxy."
19    print ""
20
21
22# New table to support user preferences.
23
24UserPreference_table = Table( "user_preference", metadata,
25    Column( "id", Integer, primary_key=True ),
26    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ),
27    Column( "name", Unicode( 255 ), index=True),
28    Column( "value", Unicode( 1024 ) ) )
29
30def upgrade():
31    display_migration_details()
32    metadata.reflect()
33    try:
34        UserPreference_table.create()
35    except Exception, e:
36        print str(e)
37        log.debug( "Creating user_preference table failed: %s" % str( e ) )
38
39def downgrade():
40    metadata.reflect()
41    try:
42        UserPreference_table.drop()
43    except Exception, e:
44        print str(e)
45        log.debug( "Dropping user_preference table failed: %s" % str( e ) )
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。