mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-10 07:24:25 +02:00
DbMigrationStep: Don't cache sql statements unnecessarily
This commit is contained in:
parent
864a78302f
commit
fac3855a86
@ -9,9 +9,6 @@ use RuntimeException;
|
|||||||
|
|
||||||
class DbMigrationStep
|
class DbMigrationStep
|
||||||
{
|
{
|
||||||
/** @var string The sql string to be executed */
|
|
||||||
protected $query;
|
|
||||||
|
|
||||||
/** @var string The sql script version the queries are loaded from */
|
/** @var string The sql script version the queries are loaded from */
|
||||||
protected $version;
|
protected $version;
|
||||||
|
|
||||||
@ -109,7 +106,6 @@ class DbMigrationStep
|
|||||||
*/
|
*/
|
||||||
public function apply(Connection $conn): self
|
public function apply(Connection $conn): self
|
||||||
{
|
{
|
||||||
if (! $this->query) {
|
|
||||||
$statements = @file_get_contents($this->getScriptPath());
|
$statements = @file_get_contents($this->getScriptPath());
|
||||||
if ($statements === false) {
|
if ($statements === false) {
|
||||||
throw new RuntimeException(sprintf('Cannot load upgrade script %s', $this->getScriptPath()));
|
throw new RuntimeException(sprintf('Cannot load upgrade script %s', $this->getScriptPath()));
|
||||||
@ -126,10 +122,7 @@ class DbMigrationStep
|
|||||||
$statements = preg_replace('/' . preg_quote($matches[1], '/') . '$/m', ';', $statements);
|
$statements = preg_replace('/' . preg_quote($matches[1], '/') . '$/m', ';', $statements);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->query = $statements;
|
$conn->exec($statements);
|
||||||
}
|
|
||||||
|
|
||||||
$conn->exec($this->query);
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user