root/galaxy-central/lib/galaxy/model/migrate/versions/0036_add_deleted_column_to_library_template_assoc_tables.py @ 2

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

import galaxy-central

行番号 
1"""
2Migration script to add a deleted column to the following tables:
3library_info_association, library_folder_info_association, library_dataset_dataset_info_association.
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    print __doc__
17    metadata.reflect()
18   
19    LibraryInfoAssociation_table = Table( "library_info_association", metadata, autoload=True )
20    c = Column( "deleted", Boolean, index=True, default=False )
21    c.create( LibraryInfoAssociation_table )
22    assert c is LibraryInfoAssociation_table.c.deleted
23    cmd = "UPDATE library_info_association SET deleted = false"
24    try:
25        db_session.execute( cmd )
26    except Exception, e:
27        log.debug( "deleted to false in library_info_association failed: %s" % ( str( e ) ) )
28   
29    LibraryFolderInfoAssociation_table = Table( "library_folder_info_association", metadata, autoload=True )
30    c = Column( "deleted", Boolean, index=True, default=False )
31    c.create( LibraryFolderInfoAssociation_table )
32    assert c is LibraryFolderInfoAssociation_table.c.deleted
33    cmd = "UPDATE library_folder_info_association SET deleted = false"
34    try:
35        db_session.execute( cmd )
36    except Exception, e:
37        log.debug( "deleted to false in library_folder_info_association failed: %s" % ( str( e ) ) )
38
39    LibraryDatasetDatasetInfoAssociation_table = Table( "library_dataset_dataset_info_association", metadata, autoload=True )
40    c = Column( "deleted", Boolean, index=True, default=False )
41    c.create( LibraryDatasetDatasetInfoAssociation_table )
42    assert c is LibraryDatasetDatasetInfoAssociation_table.c.deleted
43    cmd = "UPDATE library_dataset_dataset_info_association SET deleted = false"
44    try:
45        db_session.execute( cmd )
46    except Exception, e:
47        log.debug( "deleted to false in library_dataset_dataset_info_association failed: %s" % ( str( e ) ) )
48
49def downgrade():
50    pass
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。