root/galaxy-central/lib/galaxy/model/migrate/versions/0030_history_slug_column.py

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

import galaxy-central

行番号 
1"""
2Migration script to add column for a history slug.
3"""
4
5from sqlalchemy import *
6from migrate import *
7from migrate.changeset import *
8
9import logging
10log = logging.getLogger( __name__ )
11
12metadata = MetaData( migrate_engine )
13
14def upgrade():
15   
16    print __doc__
17    metadata.reflect()
18   
19    History_table = Table( "history", metadata, autoload=True )
20   
21    # Create slug column.
22    c = Column( "slug", TEXT, index=True )
23    c.create( History_table )
24    assert c is History_table.c.slug
25   
26    # Create slug index.
27    try:
28        i = Index( "ix_history_slug", History_table.c.slug )
29        i.create()
30    except:
31        # Mysql doesn't have a named index, but alter should work
32        History_table.c.slug.alter( unique=False )
33
34def downgrade():
35    metadata.reflect()
36
37    History_table = Table( "history", metadata, autoload=True )
38    History_table.c.slug.drop()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。