root/galaxy-central/lib/galaxy/model/migrate/versions/0010_hda_display_at_authz_table.py

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

import galaxy-central

行番号 
1"""
2This migration script adds the history_dataset_association_display_at_authorization table,
3which allows 'private' datasets to be displayed at external sites without making them public.
4If using mysql, this script will display the following error, which is corrected in the next
5migration script:
6
7history_dataset_association_display_at_authorization table failed:  (OperationalError)
8(1059, "Identifier name  'ix_history_dataset_association_display_at_authorization_update_time' 
9is too long
10"""
11from sqlalchemy import *
12from sqlalchemy.orm import *
13from sqlalchemy.exc import *
14from migrate import *
15from migrate.changeset import *
16
17import datetime
18now = datetime.datetime.utcnow
19
20import sys, logging
21log = logging.getLogger( __name__ )
22log.setLevel(logging.DEBUG)
23handler = logging.StreamHandler( sys.stdout )
24format = "%(name)s %(levelname)s %(asctime)s %(message)s"
25formatter = logging.Formatter( format )
26handler.setFormatter( formatter )
27log.addHandler( handler )
28
29# Need our custom types, but don't import anything else from model
30from galaxy.model.custom_types import *
31
32metadata = MetaData( migrate_engine )
33db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) )
34
35def display_migration_details():
36    print "========================================"
37    print "This migration script adds the history_dataset_association_display_at_authorization table, which"
38    print "allows 'private' datasets to be displayed at external sites without making them public."
39    print ""
40    print "If using mysql, this script will display the following error, which is corrected in the next migration"
41    print "script: history_dataset_association_display_at_authorization table failed:  (OperationalError)"
42    print "(1059, 'Identifier name  'ix_history_dataset_association_display_at_authorization_update_time'"
43    print "is too long."
44    print "========================================"
45
46HistoryDatasetAssociationDisplayAtAuthorization_table = Table( "history_dataset_association_display_at_authorization", metadata,
47    Column( "id", Integer, primary_key=True ),
48    Column( "create_time", DateTime, default=now ),
49    Column( "update_time", DateTime, index=True, default=now, onupdate=now ),
50    Column( "history_dataset_association_id", Integer, ForeignKey( "history_dataset_association.id" ), index=True ),
51    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ),
52    Column( "site", TrimmedString( 255 ) ) )
53
54def upgrade():
55    display_migration_details()
56    # Load existing tables
57    metadata.reflect()
58    try:
59        HistoryDatasetAssociationDisplayAtAuthorization_table.create()
60    except Exception, e:
61        log.debug( "Creating history_dataset_association_display_at_authorization table failed: %s" % str( e ) ) 
62
63def downgrade():
64    # Load existing tables
65    metadata.reflect()
66    try:
67        HistoryDatasetAssociationDisplayAtAuthorization_table.drop()
68    except Exception, e:
69        log.debug( "Dropping history_dataset_association_display_at_authorization table failed: %s" % str( e ) ) 
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。