-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration to upgrade version commands when unset
Contents based on the values in the DefaultData/LanguageFixture.
- Loading branch information
Showing
2 changed files
with
87 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20240511091916 extends AbstractMigration | ||
{ | ||
private const COMPILER_VERSION_COMMAND = ['adb'=> 'gnatmake --version', | ||
'awk'=> 'awk --version', | ||
'bash'=> 'bash --version', | ||
'c' => 'gcc --version', | ||
'cpp' => 'g++ --version', | ||
'csharp' => 'mcs --version', | ||
'f95' => 'gfortran --version', | ||
'hs' => 'ghc --version', | ||
'java' => 'javac --version', | ||
'js' => 'nodejs --version', | ||
'kt' => 'kotlinc --version', | ||
'lua' => 'luac -v', | ||
'pas' => 'fpc -iW', | ||
'pl' => 'perl -v', | ||
'plg' => 'swipl --version', | ||
'py3' => 'pypy3 --version', | ||
'ocaml' => 'ocamlopt --version', | ||
'r' => 'Rscript --version', | ||
'rb' => 'ruby --version', | ||
'rs' => 'rustc --version', | ||
'scala' => 'scalac --version', | ||
'sh' => 'md5sum /bin/sh', | ||
'swift' => 'swiftc --version']; | ||
|
||
private const RUNNER_VERSION_COMMAND = ['awk'=> 'awk --version', | ||
'bash'=> 'bash --version', | ||
'csharp' => 'mono --version', | ||
'java' => 'java --version', | ||
'js' => 'nodejs --version', | ||
'kt' => 'kotlin --version', | ||
'lua' => 'lua -v', | ||
'pl' => 'perl -v', | ||
'py3' => 'pypy3 --version', | ||
'r' => 'Rscript --version', | ||
'rb' => 'ruby --version', | ||
'scala' => 'scala --version', | ||
'sh' => 'md5sum /bin/sh']; | ||
|
||
public function getDescription(): string | ||
{ | ||
return 'Fill default version command for compiler/runner.'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
foreach (self::COMPILER_VERSION_COMMAND as $lang => $versionCommand) { | ||
$this->addSql("UPDATE language SET compiler_version_command = '" . $versionCommand ."' WHERE langid='" . $lang . "' AND compiler_version_command IS NULL;"); | ||
} | ||
foreach (self::RUNNER_VERSION_COMMAND as $lang => $versionCommand) { | ||
$this->addSql("UPDATE language SET runner_version_command = '" . $versionCommand ."' WHERE langid='" . $lang . "' AND runner_version_command IS NULL;"); | ||
} | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
foreach (self::COMPILER_VERSION_COMMAND as $lang => $versionCommand) { | ||
$this->addSql("UPDATE language SET compiler_version_command = NULL WHERE langid='" . $lang . "' AND compiler_version_command = '" . $versionCommand ."';"); | ||
} | ||
foreach (self::RUNNER_VERSION_COMMAND as $lang => $versionCommand) { | ||
$this->addSql("UPDATE language SET runner_version_command = NULL WHERE langid='" . $lang . "' AND runner_version_command = '" . $versionCommand ."';"); | ||
} | ||
} | ||
|
||
public function isTransactional(): bool | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters