Skip to content

Commit 7a5e397

Browse files
tom93vmcj
authored andcommitted
Prefer addSql() over executeStatement() in migrations
executeStatement() doesn't work well in migrations; for example it doesn't respect the --dry-run option. In Version20210407120356.php it's not possible to use addSql(), because the statements use the results of previous statements. This commit changes that file to use *only* executeStatement() for consistency. Also remove an unused import.
1 parent 32e7ede commit 7a5e397

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

webapp/migrations/Version20210407120356.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function up(Schema $schema) : void
6666
);
6767
}
6868

69-
$this->addSql('ALTER TABLE `executable` DROP COLUMN `zipfile`');
69+
$this->connection->executeStatement('ALTER TABLE `executable` DROP COLUMN `zipfile`');
7070
}
7171
}
7272

webapp/migrations/Version20230508180000.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace DoctrineMigrations;
66

7-
use App\Entity\ExecutableFile;
87
use Doctrine\DBAL\Schema\Schema;
98
use Doctrine\Migrations\AbstractMigration;
109

@@ -32,7 +31,7 @@ public function up(Schema $schema): void
3231
)
3332
)
3433
);
35-
$this->connection->executeQuery('UPDATE immutable_executable SET hash = :hash WHERE immutable_execid = :id', [
34+
$this->addSql('UPDATE immutable_executable SET hash = :hash WHERE immutable_execid = :id', [
3635
'hash' => $newHash,
3736
'id' => $immutableExecutable['immutable_execid'],
3837
]);

webapp/migrations/Version20231120225210.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function up(Schema $schema): void
3434

3535
if ($updated) {
3636
$newExtensionsJson = json_encode($extensions);
37-
$this->connection->executeQuery('UPDATE language SET extensions = :extensions WHERE langid = :langid', [
37+
$this->addSql('UPDATE language SET extensions = :extensions WHERE langid = :langid', [
3838
'extensions' => $newExtensionsJson,
3939
'langid' => $language['langid'],
4040
]);

0 commit comments

Comments
 (0)