DbMigrationStep: Don't cache sql statements unnecessarily

This commit is contained in:
Yonas Habteab 2023-09-15 11:17:05 +02:00 committed by Johannes Meyer
parent 864a78302f
commit fac3855a86
1 changed files with 15 additions and 22 deletions

View File

@ -9,9 +9,6 @@ use RuntimeException;
class DbMigrationStep
{
/** @var string The sql string to be executed */
protected $query;
/** @var string The sql script version the queries are loaded from */
protected $version;
@ -109,7 +106,6 @@ class DbMigrationStep
*/
public function apply(Connection $conn): self
{
if (! $this->query) {
$statements = @file_get_contents($this->getScriptPath());
if ($statements === false) {
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);
}
$this->query = $statements;
}
$conn->exec($this->query);
$conn->exec($statements);
return $this;
}