diff --git a/src/ORM/Connect/TempDatabase.php b/src/ORM/Connect/TempDatabase.php index b1fbecddf..ce9065bbb 100644 --- a/src/ORM/Connect/TempDatabase.php +++ b/src/ORM/Connect/TempDatabase.php @@ -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;