1 | """ |
---|
2 | Migration script to create tables for adding explicit workflow outputs. |
---|
3 | """ |
---|
4 | |
---|
5 | from sqlalchemy import * |
---|
6 | from sqlalchemy.orm import * |
---|
7 | from migrate import * |
---|
8 | from migrate.changeset import * |
---|
9 | |
---|
10 | import logging |
---|
11 | logging.basicConfig( level=logging.DEBUG ) |
---|
12 | log = logging.getLogger( __name__ ) |
---|
13 | |
---|
14 | # Need our custom types, but don't import anything else from model |
---|
15 | from galaxy.model.custom_types import * |
---|
16 | |
---|
17 | metadata = MetaData( migrate_engine ) |
---|
18 | db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) ) |
---|
19 | |
---|
20 | WorkflowOutput_table = Table( "workflow_output", metadata, |
---|
21 | Column( "id", Integer, primary_key=True ), |
---|
22 | Column( "workflow_step_id", Integer, ForeignKey("workflow_step.id"), index=True, nullable=False), |
---|
23 | Column( "output_name", String(255), nullable=True)) |
---|
24 | |
---|
25 | tables = [WorkflowOutput_table] |
---|
26 | |
---|
27 | def upgrade(): |
---|
28 | print __doc__ |
---|
29 | metadata.reflect() |
---|
30 | for table in tables: |
---|
31 | try: |
---|
32 | table.create() |
---|
33 | except: |
---|
34 | log.warn( "Failed to create table '%s', ignoring (might result in wrong schema)" % table.name ) |
---|
35 | |
---|
36 | def downgrade(): |
---|
37 | metadata.reflect() |
---|
38 | for table in tables: |
---|
39 | table.drop() |
---|