root/galaxy-central/lib/galaxy/model/migrate/versions/0028_external_metadata_file_override.py

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

import galaxy-central

行番号 
1"""
2This script adds the filename_override_metadata column to the JobExternalOutputMetadata table,
3allowing existing metadata files to be written when using external metadata and a cluster
4set up with read-only access to database/files
5"""
6from sqlalchemy import *
7from sqlalchemy.orm import *
8from sqlalchemy.exceptions import *
9from migrate import *
10from migrate.changeset import *
11import datetime
12now = datetime.datetime.utcnow
13import sys, logging
14# Need our custom types, but don't import anything else from model
15from galaxy.model.custom_types import *
16
17log = logging.getLogger( __name__ )
18log.setLevel(logging.DEBUG)
19handler = logging.StreamHandler( sys.stdout )
20format = "%(name)s %(levelname)s %(asctime)s %(message)s"
21formatter = logging.Formatter( format )
22handler.setFormatter( formatter )
23log.addHandler( handler )
24
25metadata = MetaData( migrate_engine )
26db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) )
27
28def display_migration_details():
29    print "========================================"
30    print "This script adds the filename_override_metadata column to the JobExternalOutputMetadata table,"
31    print" allowing existing metadata files to be written when using external metadata and a cluster"
32    print "set up with read-only access to database/files"
33    print "========================================"
34def upgrade():
35    display_migration_details()
36    # Load existing tables
37    metadata.reflect()
38    try:
39        job_external_output_metadata = Table( "job_external_output_metadata", metadata, autoload=True )
40        col = Column( "filename_override_metadata", String( 255 ) )
41        col.create( job_external_output_metadata )
42        assert col is job_external_output_metadata.c.filename_override_metadata
43    except Exception, e:
44        log.debug( "Adding column 'filename_override_metadata' to job_external_output_metadata table failed: %s" % ( str( e ) ) )
45
46def downgrade():
47    pass
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。