1 | """ |
---|
2 | This migration script adds the history_dataset_association_display_at_authorization table, |
---|
3 | which allows 'private' datasets to be displayed at external sites without making them public. |
---|
4 | If using mysql, this script will display the following error, which is corrected in the next |
---|
5 | migration script: |
---|
6 | |
---|
7 | history_dataset_association_display_at_authorization table failed: (OperationalError) |
---|
8 | (1059, "Identifier name 'ix_history_dataset_association_display_at_authorization_update_time' |
---|
9 | is too long |
---|
10 | """ |
---|
11 | from sqlalchemy import * |
---|
12 | from sqlalchemy.orm import * |
---|
13 | from sqlalchemy.exc import * |
---|
14 | from migrate import * |
---|
15 | from migrate.changeset import * |
---|
16 | |
---|
17 | import datetime |
---|
18 | now = datetime.datetime.utcnow |
---|
19 | |
---|
20 | import sys, logging |
---|
21 | log = logging.getLogger( __name__ ) |
---|
22 | log.setLevel(logging.DEBUG) |
---|
23 | handler = logging.StreamHandler( sys.stdout ) |
---|
24 | format = "%(name)s %(levelname)s %(asctime)s %(message)s" |
---|
25 | formatter = logging.Formatter( format ) |
---|
26 | handler.setFormatter( formatter ) |
---|
27 | log.addHandler( handler ) |
---|
28 | |
---|
29 | # Need our custom types, but don't import anything else from model |
---|
30 | from galaxy.model.custom_types import * |
---|
31 | |
---|
32 | metadata = MetaData( migrate_engine ) |
---|
33 | db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) ) |
---|
34 | |
---|
35 | def 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 | |
---|
46 | HistoryDatasetAssociationDisplayAtAuthorization_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 | |
---|
54 | def 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 | |
---|
63 | def 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 ) ) |
---|