root/galaxy-central/lib/galaxy/model/migrate/versions/0041_workflow_invocation.py

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

import galaxy-central

行番号 
1"""
2Migration script to create tables for tracking workflow invocations.
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
14import datetime
15now = datetime.datetime.utcnow
16
17metadata = MetaData( migrate_engine )
18db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) )
19
20WorkflowInvocation_table = Table( "workflow_invocation", metadata,
21    Column( "id", Integer, primary_key=True ),
22    Column( "create_time", DateTime, default=now ),
23    Column( "update_time", DateTime, default=now, onupdate=now ),
24    Column( "workflow_id", Integer, ForeignKey( "workflow.id" ), index=True, nullable=False )
25    )
26
27WorkflowInvocationStep_table = Table( "workflow_invocation_step", metadata,
28    Column( "id", Integer, primary_key=True ),
29    Column( "create_time", DateTime, default=now ),
30    Column( "update_time", DateTime, default=now, onupdate=now ),
31    Column( "workflow_invocation_id", Integer, ForeignKey( "workflow_invocation.id" ), index=True, nullable=False ),
32    Column( "workflow_step_id",  Integer, ForeignKey( "workflow_step.id" ), index=True, nullable=False ),
33    Column( "job_id",  Integer, ForeignKey( "job.id" ), index=True, nullable=False )
34    )
35
36tables = [ WorkflowInvocation_table, WorkflowInvocationStep_table ]
37   
38def upgrade():
39    print __doc__
40    metadata.reflect()
41
42    for table in tables:
43        try:
44            table.create()
45        except:
46            log.warn( "Failed to create table '%s', ignoring (might result in wrong schema)" % table.name )
47       
48def downgrade():
49    metadata.reflect()
50
51    for table in tables:
52        table.drop()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。