root/galaxy-central/lib/galaxy/model/migrate/versions/0049_api_keys_table.py

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

import galaxy-central

行番号 
1"""
2Migration script to add the api_keys 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( migrate_engine )
17
18APIKeys_table = Table( "api_keys", metadata,
19    Column( "id", Integer, primary_key=True ),
20    Column( "create_time", DateTime, default=now ),
21    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ),
22    Column( "key", TrimmedString( 32 ), index=True, unique=True ) )
23
24def upgrade():
25    print __doc__
26    metadata.reflect()
27    try:
28        APIKeys_table.create()
29    except Exception, e:
30        log.debug( "Creating api_keys table failed: %s" % str( e ) )
31
32def downgrade():
33    # Load existing tables
34    metadata.reflect()
35    try:
36        APIKeys_table.drop()
37    except Exception, e:
38        log.debug( "Dropping api_keys table failed: %s" % str( e ) )
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。