Skip to content

Commit

Permalink
Force db drop for this new command. (#81)
Browse files Browse the repository at this point in the history
kporras07 authored Aug 3, 2022
1 parent b11576f commit c97ce25
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Cli/ProjectCommands.php
Original file line number Diff line number Diff line change
@@ -335,6 +335,7 @@ public function projectUpstreamPushTags($remote, $options = ['as' => 'default',
$remote_repo = $this->createRemote($remote, $api);
$update_parameters = $this->getConfig()->get("projects.$remote.upstream.update-parameters", []);
$update_parameters['meta']['name'] = $remote_repo->projectWithOrg();
$update_parameters['force-db-drop'] = true;
$major = $this->getConfig()->get("projects.$remote.upstream.major", '[0-9]+');

$upstream_repo_url = $this->getConfig()->get("projects.$remote.upstream.repo");
9 changes: 5 additions & 4 deletions src/Update/Methods/WpCliUpdate.php
Original file line number Diff line number Diff line change
@@ -83,6 +83,7 @@ public function findLatestVersion($major, $tag_prefix, $update_parameters)
*/
public function update(WorkingCopy $originalProject, array $parameters)
{
$forceDbDrop = !empty($parameters['force-db-drop']) ?? false;
$path = $originalProject->dir();

$wpConfigPath = "$path/wp-config.php";
@@ -92,7 +93,7 @@ public function update(WorkingCopy $originalProject, array $parameters)
try {
// Set up a local WordPress site
$this->wpCoreConfig($path, $this->dbhost, $this->dbname, $this->dbuser, $this->dbpw);
$this->wpDbDropIfNotCI($path);
$this->wpDbDropIfNotCI($path, $forceDbDrop);
$this->wpDbCreate($path);
$this->wpCoreInstall($path, $this->url, $this->title, $this->admin, $this->adminPw, $this->adminEmail);

@@ -102,7 +103,7 @@ public function update(WorkingCopy $originalProject, array $parameters)
} catch (\Exception $e) {
throw $e;
} finally {
$this->wpDbDropIfNotCI($path);
$this->wpDbDropIfNotCI($path, $forceDbDrop);
file_put_contents($wpConfigPath, $wpConfigData);
}
return $originalProject;
@@ -151,9 +152,9 @@ protected function wpDbCreate($path)
/**
* Call 'db drop', but only if not running on a CI server
*/
protected function wpDbDropIfNotCI($path)
protected function wpDbDropIfNotCI($path, $force = false)
{
if (!getenv('CI')) {
if (!getenv('CI') || $force) {
$this->wpDbDrop($path);
}
}

0 comments on commit c97ce25

Please sign in to comment.