def handle_module_upgrade_request(controller, module_id, pipeline):
    # Before 0.0.3, SQLSource's resultSet output was type ListOfElements (which
    #   doesn't exist anymore)
    # In 0.0.3, SQLSource's resultSet output was type List
    # In 0.1.0, SQLSource's output was renamed to result and is now a Table;
    #   this is totally incompatible and no upgrade code is possible
    #   the resultSet is kept for now for compatibility

    # Up to 0.0.4, DBConnection would ask for a password if one was necessary;
    #   this behavior has not been kept. There is now a password input port, to
    #   which you can connect a PasswordDialog from package dialogs if needed

    old_module = pipeline.modules[module_id]
    # DBConnection module from before 0.1.0: automatically add the password
    # prompt module
    if (old_module.name == 'DBConnection' and
            versions_increasing(old_module.version, '0.1.0')):
        reg = get_module_registry()
        # Creates the new module
        new_module = controller.create_module_from_descriptor(
                reg.get_descriptor(DBConnection))
        # Create the password module
        mod_desc = reg.get_descriptor_by_name(
                'org.vistrails.vistrails.dialogs', 'PasswordDialog')
        mod = controller.create_module_from_descriptor(mod_desc)
        # Adds a 'label' function to the password module
        ops = [('add', mod)]
        ops.extend(controller.update_function_ops(mod,
                                                  'label', ['Server password']))
        # Connects the password module to the new module
        conn = controller.create_connection(mod, 'result',
                                            new_module, 'password')
        ops.append(('add', conn))
        # Replaces the old module with the new one
        upgrade_actions = UpgradeWorkflowHandler.replace_generic(
                controller, pipeline,
                old_module, new_module,
                src_port_remap={'self': 'connection'})
        password_fix_action = create_action(ops)
        return upgrade_actions + [password_fix_action]

    return UpgradeWorkflowHandler.attempt_automatic_upgrade(
            controller, pipeline,
            module_id)


###############################################################################
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/packages/sql/init.py/handle_module_upgrade_request/original