|
| 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 Version20241018061817 extends AbstractMigration |
| 14 | +{ |
| 15 | + public function getDescription(): string |
| 16 | + { |
| 17 | + return 'Allow storing visualization of team output.'; |
| 18 | + } |
| 19 | + |
| 20 | + public function up(Schema $schema): void |
| 21 | + { |
| 22 | + $this->addSql('ALTER TABLE problem ADD special_output_visualizer VARCHAR(32) DEFAULT NULL COMMENT \'Executable ID (string)\', CHANGE multipass_limit multipass_limit INT UNSIGNED DEFAULT NULL COMMENT \'Optional limit on the number of rounds; defaults to 1 for traditional problems, 2 for multi-pass problems if not specified.\''); |
| 23 | + $this->addSql('ALTER TABLE problem ADD CONSTRAINT FK_D7E7CCC819F5352E FOREIGN KEY (special_output_visualizer) REFERENCES executable (execid) ON DELETE SET NULL'); |
| 24 | + $this->addSql('CREATE INDEX special_output_visualizer ON problem (special_output_visualizer)'); |
| 25 | + $this->addSql('ALTER TABLE judgetask ADD output_visualizer_script_id INT UNSIGNED DEFAULT NULL COMMENT \'Output visualizer script ID\''); |
| 26 | + $this->addSql('ALTER TABLE `judgetask` |
| 27 | + MODIFY COLUMN `type` ENUM(\'judging_run\', \'generic_task\', \'config_check\', \'debug_info\', \'prefetch\', \'output_visualization\') DEFAULT \'judging_run\' NOT NULL COMMENT \'Type of the judge task.(DC2Type:judge_task_type)\''); |
| 28 | + $this->addSql('ALTER TABLE judging ADD visualization TINYINT(1) DEFAULT 0 NOT NULL COMMENT \'Explicitly requested to visualize the output.\''); |
| 29 | + $this->addSql('CREATE TABLE visualization (visualization_id INT UNSIGNED AUTO_INCREMENT NOT NULL COMMENT \'Visualization ID\', judgingid INT UNSIGNED DEFAULT NULL COMMENT \'Judging ID\', judgehostid INT UNSIGNED DEFAULT NULL COMMENT \'Judgehost ID\', testcaseid INT UNSIGNED DEFAULT NULL COMMENT \'Testcase ID\', filename VARCHAR(255) NOT NULL COMMENT \'Name of the file where we stored the visualization.\', INDEX IDX_E0936C40E0E4FC3E (judgehostid), INDEX IDX_E0936C40D360BB2B (testcaseid), INDEX judgingid (judgingid), PRIMARY KEY(visualization_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'Team output visualization.\' '); |
| 30 | + $this->addSql('ALTER TABLE visualization ADD CONSTRAINT FK_E0936C405D5FEA72 FOREIGN KEY (judgingid) REFERENCES judging (judgingid) ON DELETE CASCADE'); |
| 31 | + $this->addSql('ALTER TABLE visualization ADD CONSTRAINT FK_E0936C40E0E4FC3E FOREIGN KEY (judgehostid) REFERENCES judgehost (judgehostid) ON DELETE SET NULL'); |
| 32 | + $this->addSql('ALTER TABLE visualization ADD CONSTRAINT FK_E0936C40D360BB2B FOREIGN KEY (testcaseid) REFERENCES testcase (testcaseid) ON DELETE CASCADE'); |
| 33 | + |
| 34 | + } |
| 35 | + |
| 36 | + public function down(Schema $schema): void |
| 37 | + { |
| 38 | + $this->addSql('ALTER TABLE visualization DROP FOREIGN KEY FK_E0936C405D5FEA72'); |
| 39 | + $this->addSql('ALTER TABLE visualization DROP FOREIGN KEY FK_E0936C40E0E4FC3E'); |
| 40 | + $this->addSql('ALTER TABLE visualization DROP FOREIGN KEY FK_E0936C40D360BB2B'); |
| 41 | + $this->addSql('DROP TABLE visualization'); |
| 42 | + $this->addSql('ALTER TABLE judging DROP visualization'); |
| 43 | + $this->addSql('ALTER TABLE `judgetask` |
| 44 | + MODIFY COLUMN `type` ENUM(\'judging_run\', \'generic_task\', \'config_check\', \'debug_info\', \'prefetch\') DEFAULT \'judging_run\' NOT NULL COMMENT \'Type of the judge task.(DC2Type:judge_task_type)\''); |
| 45 | + $this->addSql('ALTER TABLE judgetask DROP output_visualizer_script_id'); |
| 46 | + $this->addSql('ALTER TABLE problem DROP FOREIGN KEY FK_D7E7CCC819F5352E'); |
| 47 | + $this->addSql('DROP INDEX special_output_visualizer ON problem'); |
| 48 | + $this->addSql('ALTER TABLE problem DROP special_output_visualizer, CHANGE multipass_limit multipass_limit INT UNSIGNED DEFAULT NULL COMMENT \'Optional limit on the number of rounds for multi-pass problems; defaults to 2 if not specified.\''); |
| 49 | + |
| 50 | + } |
| 51 | + |
| 52 | + public function isTransactional(): bool |
| 53 | + { |
| 54 | + return false; |
| 55 | + } |
| 56 | +} |
0 commit comments