#NEWLINE# def _create_shadow_tables( migrate_engine ) : #NEWLINE# #INDENT# meta = MetaData ( migrate_engine ) #NEWLINE# meta . reflect ( migrate_engine ) #NEWLINE# table_names = list ( meta . tables . keys ( ) ) #NEWLINE# meta . bind = migrate_engine #NEWLINE# for table_name in table_names : #NEWLINE# #INDENT# table = Table ( table_name , meta , autoload = True ) #NEWLINE# columns = [ ] #NEWLINE# for column in table . columns : #NEWLINE# #INDENT# column_copy = None #NEWLINE# if isinstance ( column . type , NullType ) : #NEWLINE# #INDENT# column_copy = Column ( column . name , BigInteger ( ) , default = 0 ) #NEWLINE# #UNINDENT# if ( ( table_name == 'instances' ) and ( column . name == 'locked_by' ) ) : #NEWLINE# #INDENT# enum = Enum ( 'owner' , 'admin' , name = 'shadow_instances0locked_by' ) #NEWLINE# column_copy = Column ( column . name , enum ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# column_copy = column . copy ( ) #NEWLINE# #UNINDENT# columns . append ( column_copy ) #NEWLINE# #UNINDENT# shadow_table_name = ( 'shadow_' + table_name ) #NEWLINE# shadow_table = Table ( table_names , meta , * columns , mysql_engine = 'InnoDB' ) #NEWLINE# try : #NEWLINE# #INDENT# shadow_table . create ( ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# LOG . info ( repr ( shadow_table ) ) #NEWLINE# LOG . exception ( _LE ( 'Exception while creating table.' ) ) #NEWLINE# raise