Skip to content

Commit 6782afc

Browse files
committed
Add migration to upgrade version commands when unset
Contents based on the values in the DefaultData/LanguageFixture.
1 parent a546e78 commit 6782afc

File tree

2 files changed

+87
-5
lines changed

2 files changed

+87
-5
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20240511091916 extends AbstractMigration
14+
{
15+
private const COMPILER_VERSION_COMMAND = ['adb'=> 'gnatmake --version',
16+
'awk'=> 'awk --version',
17+
'bash'=> 'bash --version',
18+
'c' => 'gcc --version',
19+
'cpp' => 'g++ --version',
20+
'csharp' => 'mcs --version',
21+
'f95' => 'gfortran --version',
22+
'hs' => 'ghc --version',
23+
'java' => 'javac --version',
24+
'js' => 'nodejs --version',
25+
'kt' => 'kotlinc --version',
26+
'lua' => 'luac -v',
27+
'pas' => 'fpc -iW',
28+
'pl' => 'perl -v',
29+
'plg' => 'swipl --version',
30+
'py3' => 'pypy3 --version',
31+
'ocaml' => 'ocamlopt --version',
32+
'r' => 'Rscript --version',
33+
'rb' => 'ruby --version',
34+
'rs' => 'rustc --version',
35+
'scala' => 'scalac --version',
36+
'sh' => 'md5sum /bin/sh',
37+
'swift' => 'swiftc --version'];
38+
39+
private const RUNNER_VERSION_COMMAND = ['awk'=> 'awk --version',
40+
'bash'=> 'bash --version',
41+
'csharp' => 'mono --version',
42+
'java' => 'java --version',
43+
'js' => 'nodejs --version',
44+
'kt' => 'kotlin --version',
45+
'lua' => 'lua -v',
46+
'pl' => 'perl -v',
47+
'py3' => 'pypy3 --version',
48+
'r' => 'Rscript --version',
49+
'rb' => 'ruby --version',
50+
'scala' => 'scala --version',
51+
'sh' => 'md5sum /bin/sh'];
52+
53+
public function getDescription(): string
54+
{
55+
return 'Fill default version command for compiler/runner.';
56+
}
57+
58+
public function up(Schema $schema): void
59+
{
60+
foreach (self::COMPILER_VERSION_COMMAND as $lang => $versionCommand) {
61+
$this->addSql("UPDATE language SET compiler_version_command = '" . $versionCommand ."' WHERE langid='" . $lang . "' AND compiler_version_command IS NULL;");
62+
}
63+
foreach (self::RUNNER_VERSION_COMMAND as $lang => $versionCommand) {
64+
$this->addSql("UPDATE language SET runner_version_command = '" . $versionCommand ."' WHERE langid='" . $lang . "' AND runner_version_command IS NULL;");
65+
}
66+
}
67+
68+
public function down(Schema $schema): void
69+
{
70+
foreach (self::COMPILER_VERSION_COMMAND as $lang => $versionCommand) {
71+
$this->addSql("UPDATE language SET compiler_version_command = NULL WHERE langid='" . $lang . "' AND compiler_version_command = '" . $versionCommand ."';");
72+
}
73+
foreach (self::RUNNER_VERSION_COMMAND as $lang => $versionCommand) {
74+
$this->addSql("UPDATE language SET runner_version_command = NULL WHERE langid='" . $lang . "' AND runner_version_command = '" . $versionCommand ."';");
75+
}
76+
}
77+
78+
public function isTransactional(): bool
79+
{
80+
return false;
81+
}
82+
}

webapp/src/DataFixtures/DefaultData/LanguageFixture.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,27 @@ public function load(ObjectManager $manager): void
2626
// ID external ID name extensions require entry point allow allow time compile compiler version runner version
2727
// entry point description submit judge factor script command command
2828
['adb', 'ada', 'Ada', ['adb', 'ads'], false, null, false, true, 1, 'adb', 'gnatmake --version', ''],
29-
['awk', 'awk', 'AWK', ['awk'], false, null, false, true, 1, 'awk', 'awk --version', ''],
30-
['bash', 'bash', 'Bash shell', ['bash'], false, 'Main file', false, true, 1, 'bash', 'bash --version', ''],
29+
['awk', 'awk', 'AWK', ['awk'], false, null, false, true, 1, 'awk', 'awk --version', 'awk --version'],
30+
['bash', 'bash', 'Bash shell', ['bash'], false, 'Main file', false, true, 1, 'bash', 'bash --version', 'bash --version'],
3131
['c', 'c', 'C', ['c'], false, null, true, true, 1, 'c', 'gcc --version', ''],
3232
['cpp', 'cpp', 'C++', ['cpp', 'cc', 'cxx', 'c++'], false, null, true, true, 1, 'cpp', 'g++ --version', ''],
3333
['csharp', 'csharp', 'C#', ['csharp', 'cs'], false, null, false, true, 1, 'csharp', 'mcs --version', 'mono --version'],
3434
['f95', 'f95', 'Fortran', ['f95', 'f90'], false, null, false, true, 1, 'f95', 'gfortran --version', ''],
3535
['hs', 'haskell', 'Haskell', ['hs', 'lhs'], false, null, false, true, 1, 'hs', 'ghc --version', ''],
3636
['java', 'java', 'Java', ['java'], false, 'Main class', true, true, 1, 'java_javac_detect', 'javac -version', 'java -version'],
3737
['js', 'javascript', 'JavaScript', ['js'], false, 'Main file', false, true, 1, 'js', 'nodejs --version', 'nodejs --version'],
38-
['lua', 'lua', 'Lua', ['lua'], false, null, false, true, 1, 'lua', 'luac -v', ''],
38+
['lua', 'lua', 'Lua', ['lua'], false, null, false, true, 1, 'lua', 'luac -v', 'lua -v'],
3939
['kt', 'kotlin', 'Kotlin', ['kt'], true, 'Main class', false, true, 1, 'kt', 'kotlinc -version', 'kotlin -version'],
4040
['pas', 'pascal', 'Pascal', ['pas', 'p'], false, 'Main file', false, true, 1, 'pas', 'fpc -iW', ''],
4141
['pl', 'pl', 'Perl', ['pl'], false, 'Main file', false, true, 1, 'pl', 'perl -v', 'perl -v'],
42-
['plg', 'prolog', 'Prolog', ['plg'], false, 'Main file', false, true, 1, 'plg', 'swipl --version', 'swipl --version'],
42+
['plg', 'prolog', 'Prolog', ['plg'], false, 'Main file', false, true, 1, 'plg', 'swipl --version', ''],
4343
['py3', 'python3', 'Python 3', ['py'], false, 'Main file', true, true, 1, 'py3', 'pypy3 --version', 'pypy3 --version'],
4444
['ocaml', 'ocaml', 'OCaml', ['ml'], false, null, false, true, 1, 'ocaml', 'ocamlopt --version', ''],
4545
['r', 'r', 'R', ['R'], false, 'Main file', false, true, 1, 'r', 'Rscript --version', 'Rscript --version'],
4646
['rb', 'ruby', 'Ruby', ['rb'], false, 'Main file', false, true, 1, 'rb', 'ruby --version', 'ruby --version'],
4747
['rs', 'rust', 'Rust', ['rs'], false, null, false, true, 1, 'rs', 'rustc --version', ''],
4848
['scala', 'scala', 'Scala', ['scala'], false, null, false, true, 1, 'scala', 'scalac -version', 'scala -version'],
49-
['sh', 'sh', 'POSIX shell', ['sh'], false, 'Main file', false, true, 1, 'sh', 'md5sum /bin/sh', ''],
49+
['sh', 'sh', 'POSIX shell', ['sh'], false, 'Main file', false, true, 1, 'sh', 'md5sum /bin/sh', 'md5sum /bin/sh'],
5050
['swift', 'swift', 'Swift', ['swift'], false, 'Main file', false, true, 1, 'swift', 'swiftc --version', ''],
5151
];
5252

0 commit comments

Comments
 (0)