setup/src/Magento/Setup/Model/Installer.php#L820-L857
foreach ($moduleNames as $moduleName) {
$this->log->log("Module '{$moduleName}':");
$configVer = $this->moduleList->getOne($moduleName)['setup_version'];
$currentVersion = $moduleContextList[$moduleName]->getVersion();
// Schema/Data is installed
if ($currentVersion !== '') {
$status = version_compare($configVer, $currentVersion);
if ($status == \Magento\Framework\Setup\ModuleDataSetupInterface::VERSION_COMPARE_GREATER) {
$upgrader = $this->getSchemaDataHandler($moduleName, $upgradeType);
if ($upgrader) {
$this->log->logInline("Upgrading $type.. ");
$upgrader->upgrade($setup, $moduleContextList[$moduleName]);
}
if ($type === 'schema') {
$resource->setDbVersion($moduleName, $configVer);
} elseif ($type === 'data') {
$resource->setDataVersion($moduleName, $configVer);
}
}
} elseif ($configVer) {
$installer = $this->getSchemaDataHandler($moduleName, $installType);
if ($installer) {
$this->log->logInline("Installing $type... ");
$installer->install($setup, $moduleContextList[$moduleName]);
}
$upgrader = $this->getSchemaDataHandler($moduleName, $upgradeType);
if ($upgrader) {
$this->log->logInline("Upgrading $type... ");
$upgrader->upgrade($setup, $moduleContextList[$moduleName]);
}
if ($type === 'schema') {
$resource->setDbVersion($moduleName, $configVer);
} elseif ($type === 'data') {
$resource->setDataVersion($moduleName, $configVer);
}
}
$this->logProgress();
}