root/galaxy-central/lib/galaxy/model/migrate/versions/0040_page_annotations.py

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

import galaxy-central

行番号 
1"""
2Migration script to (a) create tables for annotating pages.
3"""
4
5from sqlalchemy import *
6from sqlalchemy.orm import *
7from migrate import *
8from migrate.changeset import *
9
10import logging
11log = logging.getLogger( __name__ )
12
13metadata = MetaData( migrate_engine )
14db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) )
15
16PageAnnotationAssociation_table = Table( "page_annotation_association", metadata,
17    Column( "id", Integer, primary_key=True ),
18    Column( "page_id", Integer, ForeignKey( "page.id" ), index=True ),
19    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ),
20    Column( "annotation", TEXT, index=True) )
21   
22def upgrade():
23    print __doc__
24    metadata.reflect()
25
26    # Create history_annotation_association table.
27    try:
28        PageAnnotationAssociation_table.create()
29    except Exception, e:
30        print str(e)
31        log.debug( "Creating page_annotation_association table failed: %s" % str( e ) )
32       
33def downgrade():
34    metadata.reflect()
35       
36    # Drop page_annotation_association table.
37    try:
38        PageAnnotationAssociation_table.drop()
39    except Exception, e:
40       print str(e)
41       log.debug( "Dropping page_annotation_association table failed: %s" % str( e ) )
42       
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。