def changeStorageEngines(cat):
    new_engine = Workbench.input(
        'Type the new storage engine name for all tables in your model:')

    if not new_engine:
        return 1

    def getTableEngines():
        result = grt.root.wb.options.options[
            '@db.mysql.Table:tableEngine/Items']
        items = [item.strip(' \t') for item in result.split(',')]
        return items

    # validate the engine name and fix its case
    engines = getTableEngines()
    engine_found = False
    for engine_name in engines:
        if engine_name.find(':') != -1:
            engine_name = engine_name[engine_name.find(':') + 1:]
        if new_engine.lower() == engine_name.lower():
            engine_found = True
            new_engine = engine_name

    if not engine_found:
        Workbench.confirm('Change Storage Engines',
                          'Invalid storage engine name: ' + new_engine)
        return 2

    for schema in cat.schemata:
        for tbl in schema.tables:
            tbl.tableEngine = new_engine

    return 0
def changeStorageEngines(cat):
     new_engine = Workbench.input('Type the new storage engine name for all tables in your model:')
     
     if not new_engine:
       return 1
 
     def getTableEngines():
        result = grt.root.wb.options.options['@db.mysql.Table:tableEngine/Items']
        items = [item.strip(' \t') for item in result.split(',')]
        return items

     # validate the engine name and fix its case
     engines = getTableEngines()
     engine_found = False
     for engine_name in engines:
        if engine_name.find(':') != -1:
            engine_name = engine_name[engine_name.find(':') + 1:]
        if new_engine.lower() == engine_name.lower():
            engine_found = True
            new_engine = engine_name

     if not engine_found:
        Workbench.confirm('Change Storage Engines', 'Invalid storage engine name: ' + new_engine)
        return 2

     for schema in cat.schemata:
         for tbl in schema.tables:
            tbl.tableEngine = new_engine
            
     return 0
def prefixTables(cat):
    prefix = Workbench.input('Please specify the prefix')

    if not prefix:
        return 1

    for schema in cat.schemata:
        for tbl in schema.tables:
            tbl.name = prefix + tbl.name

    return 0
def prefixTables(cat):
     prefix = Workbench.input('Please specify the prefix')
     
     if not prefix:
         return 1

     for schema in cat.schemata:
         for tbl in schema.tables:
             tbl.name = prefix + tbl.name
             
     return 0