root/galaxy-central/lib/galaxy/model/migrate/versions/0022_visualization_tables.py

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

import galaxy-central

行番号 
1"""
2Migration script to add support for storing visualizations.
3  1) Creates Visualization and VisualizationRevision tables
4"""
5
6from sqlalchemy import *
7from migrate import *
8from migrate.changeset import *
9
10import datetime
11now = datetime.datetime.utcnow
12
13import logging
14log = logging.getLogger( __name__ )
15
16metadata = MetaData( migrate_engine )
17
18Visualization_table = Table( "visualization", metadata,
19    Column( "id", Integer, primary_key=True ),
20    Column( "create_time", DateTime, default=now ),
21    Column( "update_time", DateTime, default=now, onupdate=now ),
22    Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True, nullable=False ),
23    Column( "latest_revision_id", Integer,
24            ForeignKey( "visualization_revision.id", use_alter=True, name='visualization_latest_revision_id_fk' ), index=True ),
25    Column( "title", TEXT ),
26    Column( "type", TEXT )
27    )
28
29VisualizationRevision_table = Table( "visualization_revision", metadata,
30    Column( "id", Integer, primary_key=True ),
31    Column( "create_time", DateTime, default=now ),
32    Column( "update_time", DateTime, default=now, onupdate=now ),
33    Column( "visualization_id", Integer, ForeignKey( "visualization.id" ), index=True, nullable=False ),
34    Column( "title", TEXT ),
35    Column( "config", TEXT )
36    )
37
38def upgrade():
39    print __doc__
40    metadata.reflect()
41    try:
42        Visualization_table.create()
43    except:
44        log.debug( "Could not create page table" )
45    try:
46        VisualizationRevision_table.create()
47    except:
48        log.debug( "Could not create page_revision table" )
49
50
51def downgrade():
52    metadata.reflect()
53    Visualization_table.drop()
54    VisualizationRevision_table.drop()
55
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。