BUG FIx manual resetDBSchema() calls breaking the database

This commit is contained in:
Damian Mooyman 2018-06-18 17:56:42 +12:00 committed by Daniel Hensby
parent 11e0a3de43
commit 225e61dc67
No known key found for this signature in database
GPG Key ID: D8DEBC4C8E7BC8B9

View File

@ -105,7 +105,8 @@ class TempDatabase
*
* @return bool True if successfully rolled back, false otherwise. On error the DB is
* killed and must be re-created. Note that calling rollbackTransaction() when there
* is no transaction is counted as a failure, and will kill the DB.
* is no transaction is counted as a failure, user code should either kill or flush the DB
* as necessary
*/
public function rollbackTransaction()
{
@ -120,9 +121,6 @@ class TempDatabase
$success = false;
}
}
if (!$success) {
static::kill();
}
return $success;
}
@ -247,7 +245,12 @@ class TempDatabase
// pgsql doesn't allow schema updates inside transactions
// so we need to rollback any transactions before commencing a schema reset
if ($this->hasStarted()) {
$this->rollbackTransaction();
// Sometimes transactions fail, rebuild
$success = $this->rollbackTransaction();
if (!$success) {
$this->kill();
$this->build();
}
}
if (!$this->isUsed()) {
return;