Skip to content

Commit

Permalink
Merge pull request #16574 from craftcms/bugfix/16086-migrate-all-rese…
Browse files Browse the repository at this point in the history
…tting-external-pc

check if schema version has changed against the old version
  • Loading branch information
brandonkelly authored Feb 2, 2025
2 parents 653c9c1 + 5ab87ac commit c4a01cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
13 changes: 5 additions & 8 deletions src/services/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -854,14 +854,11 @@ public function updatePluginVersionInfo(PluginInterface $plugin): void
$this->_storedPluginInfo[$plugin->id]['schemaVersion'] = $plugin->schemaVersion;
}

// Only update the schema version if it's changed from what's in the file,
// so we don't accidentally overwrite other pending changes
$projectConfig = Craft::$app->getProjectConfig();
$key = ProjectConfig::PATH_PLUGINS . ".$plugin->id.schemaVersion";

if ($projectConfig->get($key, true) !== $plugin->schemaVersion) {
Craft::$app->getProjectConfig()->set($key, $plugin->schemaVersion, "Update plugin schema version for “{$plugin->handle}");
}
Craft::$app->getProjectConfig()->set(
sprintf('%s.%s.schemaVersion', ProjectConfig::PATH_PLUGINS, $plugin->id),
$plugin->schemaVersion,
"Update plugin schema version for “{$plugin->handle}",
);
}

/**
Expand Down
11 changes: 5 additions & 6 deletions src/services/Updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,11 @@ public function updateCraftVersionInfo(): bool

Craft::$app->saveInfo($info);

// Only update the schema version if it's changed from what's in the file,
// so we don't accidentally overwrite other pending changes
$projectConfig = Craft::$app->getProjectConfig();
if ($projectConfig->get(ProjectConfig::PATH_SCHEMA_VERSION, true) !== $info->schemaVersion) {
Craft::$app->getProjectConfig()->set(ProjectConfig::PATH_SCHEMA_VERSION, $info->schemaVersion, 'Update Craft schema version');
}
Craft::$app->getProjectConfig()->set(
ProjectConfig::PATH_SCHEMA_VERSION,
$info->schemaVersion,
'Update Craft schema version',
);

$this->_isCraftUpdatePending = null;

Expand Down

0 comments on commit c4a01cb

Please sign in to comment.