root/galaxy-central/lib/galaxy/model/migrate/versions/0046_post_job_actions.py @ 3

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

import galaxy-central

行番号 
1"""
2Migration script to create tables for handling post-job actions.
3"""
4
5from sqlalchemy import *
6from sqlalchemy.orm import *
7from migrate import *
8from migrate.changeset import *
9
10import logging
11logging.basicConfig( level=logging.DEBUG )
12log = logging.getLogger( __name__ )
13
14# Need our custom types, but don't import anything else from model
15from galaxy.model.custom_types import *
16
17import datetime
18now = datetime.datetime.utcnow
19
20metadata = MetaData( migrate_engine )
21db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) )
22
23PostJobAction_table = Table("post_job_action", metadata,
24    Column("id", Integer, primary_key=True),
25    Column("workflow_step_id", Integer, ForeignKey( "workflow_step.id" ), index=True, nullable=False),
26    Column("action_type", String(255), nullable=False),
27    Column("output_name", String(255), nullable=True),
28    Column("action_arguments", JSONType, nullable=True))
29
30# PostJobActionAssociation_table = Table("post_job_action_association", metadata,
31#     Column("id", Integer, primary_key=True),
32#     Column("post_job_action_id", Integer, ForeignKey("post_job_action.id"), index=True, nullable=False),
33#     Column("job_id", Integer, ForeignKey("job.id"), index=True, nullable=False))
34
35tables = [PostJobAction_table]#, PostJobActionAssociation_table]
36
37def upgrade():
38    print __doc__
39    metadata.reflect()
40    for table in tables:
41        try:
42            table.create()
43        except:
44            log.warn( "Failed to create table '%s', ignoring (might result in wrong schema)" % table.name )
45
46def downgrade():
47    metadata.reflect()
48    for table in tables:
49        table.drop()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。