[hg] galaxy 3376: Migration script fix. This restores the 'reque...
details: http://www.bx.psu.edu/hg/galaxy/rev/0f4e5a057322 changeset: 3376:0f4e5a057322 user: rc date: Fri Feb 12 11:19:37 2010 -0500 description: Migration script fix. This restores the 'request' table if it got deleted in the previous script (only for sqlite). diffstat: lib/galaxy/model/migrate/versions/0038_add_inheritable_column_to_library_template_assoc_tables.py | 31 +++++++++- 1 files changed, 30 insertions(+), 1 deletions(-) diffs (53 lines): diff -r 049a86b8691d -r 0f4e5a057322 lib/galaxy/model/migrate/versions/0038_add_inheritable_column_to_library_template_assoc_tables.py --- a/lib/galaxy/model/migrate/versions/0038_add_inheritable_column_to_library_template_assoc_tables.py Fri Feb 12 11:01:30 2010 -0500 +++ b/lib/galaxy/model/migrate/versions/0038_add_inheritable_column_to_library_template_assoc_tables.py Fri Feb 12 11:19:37 2010 -0500 @@ -1,12 +1,16 @@ """ Migration script to add an inheritable column to the following tables: library_info_association, library_folder_info_association. +Also, in case of sqlite check if the previous migration script deleted the +request table and if so, restore the table. """ from sqlalchemy import * from migrate import * from migrate.changeset import * - +from galaxy.model.custom_types import * +import datetime +now = datetime.datetime.utcnow import logging log = logging.getLogger( __name__ ) @@ -14,6 +18,31 @@ def upgrade(): print __doc__ + + # + # In case of sqlite, check if the previous migration script deleted the + # request table and if so, restore the table. + # + if migrate_engine.name == 'sqlite': + if not migrate_engine.has_table('request'): + # load the tables referenced in foreign keys + metadata.reflect(only=['form_values', 'request_type', 'galaxy_user']) + # create a temporary table + Request_table = Table( 'request', metadata, + Column( "id", Integer, primary_key=True), + Column( "create_time", DateTime, default=now ), + Column( "update_time", DateTime, default=now, onupdate=now ), + Column( "name", TrimmedString( 255 ), nullable=False ), + Column( "desc", TEXT ), + Column( "form_values_id", Integer, ForeignKey( "form_values.id" ), index=True ), + Column( "request_type_id", Integer, ForeignKey( "request_type.id" ), index=True ), + Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ), + Column( "deleted", Boolean, index=True, default=False ) ) + try: + Request_table.create() + except Exception, e: + log.debug( "Creating request table failed: %s" % str( e ) ) + metadata.reflect() LibraryInfoAssociation_table = Table( "library_info_association", metadata, autoload=True )
participants (1)
-
Greg Von Kuster