#NEWLINE# def __change_db_version( self , version , migration_file_name , sql_up , sql_down , up = True , execution_log = None , label_version = None ) : #NEWLINE# #INDENT# params = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# params [ 'version' ] = version #NEWLINE# conn = self . __connect ( ) #NEWLINE# cursor = conn . cursor ( ) #NEWLINE# if up : #NEWLINE# #INDENT# sql = ( 'insert into %s (id, version, label, name, sql_up, sql_down) values (%s_seq.nextval, :version, :label, :migration_file_name, :sql_up, :sql_down)' % ( self . __version_table , self . __version_table ) ) #NEWLINE# sql_up = ( ( sql_up and sql_up . encode ( self . __script_encoding ) ) or '' ) #NEWLINE# v_sql_up = cursor . var ( self . __driver . CLOB , len ( sql_up ) ) #NEWLINE# v_sql_up . setvalue ( 0 , sql_up ) #NEWLINE# params [ 'sql_up' ] = sql_up #NEWLINE# sql_down = ( ( sql_down and sql_down . encode ( self . __script_encoding ) ) or '' ) #NEWLINE# v_sql_down = cursor . var ( self . __driver . CLOB , len ( sql_down ) ) #NEWLINE# v_sql_down . setvalue ( 0 , sql_down ) #NEWLINE# params [ 'sql_down' ] = sql_down #NEWLINE# params [ 'migration_file_name' ] = migration_file_name #NEWLINE# params [ 'label' ] = label_version #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# sql = ( 'delete from %s where version = :version' % self . __version_table ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# cursor . execute ( sql . encode ( self . __script_encoding ) , params ) #NEWLINE# cursor . close ( ) #NEWLINE# conn . commit ( ) #NEWLINE# if execution_log : #NEWLINE# #INDENT# execution_log ( ( 'migration %s registered\n' % migration_file_name ) ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# conn . rollback ( ) #NEWLINE# raise MigrationException ( ( 'error logging migration: %s' % e ) , migration_file_name ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# conn . close ( )