PageRenderTime 22ms CodeModel.GetById 19ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/galaxy/model/migrate/versions/0023_page_published_and_deleted_columns.py

https://bitbucket.org/h_morita_dbcls/galaxy-central
Python | 35 lines | 21 code | 10 blank | 4 comment | 0 complexity | a575351a5d913184eea69e7af5d0ecbd MD5 | raw file
 1"""
 2Migration script to add columns for tracking whether pages are deleted and
 3publicly accessible.
 4"""
 5
 6from sqlalchemy import *
 7from migrate import *
 8from migrate.changeset import *
 9
10import logging
11log = logging.getLogger( __name__ )
12
13metadata = MetaData( migrate_engine )
14
15def upgrade():
16    
17    print __doc__
18    metadata.reflect()
19    
20    Page_table = Table( "page", metadata, autoload=True )
21    
22    c = Column( "published", Boolean, index=True, default=False )
23    c.create( Page_table )
24    assert c is Page_table.c.published
25    
26    c = Column( "deleted", Boolean, index=True, default=False ) 
27    c.create( Page_table )
28    assert c is Page_table.c.deleted
29
30def downgrade():
31    metadata.reflect()
32
33    Page_table = Table( "page", metadata, autoload=True )
34    Page_table.c.published.drop()
35    Page_table.c.deleted.drop()