1 | """ |
---|
2 | This script adds the filename_override_metadata column to the JobExternalOutputMetadata table, |
---|
3 | allowing existing metadata files to be written when using external metadata and a cluster |
---|
4 | set up with read-only access to database/files |
---|
5 | """ |
---|
6 | from sqlalchemy import * |
---|
7 | from sqlalchemy.orm import * |
---|
8 | from sqlalchemy.exceptions import * |
---|
9 | from migrate import * |
---|
10 | from migrate.changeset import * |
---|
11 | import datetime |
---|
12 | now = datetime.datetime.utcnow |
---|
13 | import sys, logging |
---|
14 | # Need our custom types, but don't import anything else from model |
---|
15 | from galaxy.model.custom_types import * |
---|
16 | |
---|
17 | log = logging.getLogger( __name__ ) |
---|
18 | log.setLevel(logging.DEBUG) |
---|
19 | handler = logging.StreamHandler( sys.stdout ) |
---|
20 | format = "%(name)s %(levelname)s %(asctime)s %(message)s" |
---|
21 | formatter = logging.Formatter( format ) |
---|
22 | handler.setFormatter( formatter ) |
---|
23 | log.addHandler( handler ) |
---|
24 | |
---|
25 | metadata = MetaData( migrate_engine ) |
---|
26 | db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) ) |
---|
27 | |
---|
28 | def 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 "========================================" |
---|
34 | def 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 | |
---|
46 | def downgrade(): |
---|
47 | pass |
---|