diff --git a/src/Cli/ProjectCommands.php b/src/Cli/ProjectCommands.php index ac5220fa..cdf1b5e9 100644 --- a/src/Cli/ProjectCommands.php +++ b/src/Cli/ProjectCommands.php @@ -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"); diff --git a/src/Update/Methods/WpCliUpdate.php b/src/Update/Methods/WpCliUpdate.php index fde244a3..1d1405bf 100644 --- a/src/Update/Methods/WpCliUpdate.php +++ b/src/Update/Methods/WpCliUpdate.php @@ -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); } }