#NEWLINE# def upgrade( migrate_engine ) : #NEWLINE# #INDENT# 'Change instances (project_id) index to cover (project_id, deleted).' #NEWLINE# meta = MetaData ( bind = migrate_engine ) #NEWLINE# instances = Table ( 'instances' , meta , autoload = True ) #NEWLINE# for index in instances . indexes : #NEWLINE# #INDENT# if ( [ c . name for c in index . columns ] == [ 'project_id' , 'deleted' ] ) : #NEWLINE# #INDENT# LOG . info ( _LI ( 'Skipped adding instances_project_id_deleted_idx because an equivalent index already exists.' ) ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# index = Index ( 'instances_project_id_deleted_idx' , instances . c . project_id , instances . c . deleted ) #NEWLINE# index . create ( ) #NEWLINE# #UNINDENT# for index in instances . indexes : #NEWLINE# #INDENT# if ( [ c . name for c in index . columns ] == [ 'project_id' ] ) : #NEWLINE# #INDENT# index . drop ( )