Skip to content

Commit

Permalink
Add migrations for stuff that is out of sync between models and the DB.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickygerritsen committed Nov 24, 2023
1 parent aa4f8ba commit df78c81
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
38 changes: 38 additions & 0 deletions webapp/migrations/Version20231124123934.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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 Version20231124123934 extends AbstractMigration
{
public function getDescription(): string
{
return 'Synchronize table comments with models';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE queuetask CHANGE judgingid judgingid INT UNSIGNED DEFAULT NULL COMMENT \'Judging ID\'');
$this->addSql('ALTER TABLE submission CHANGE import_error import_error VARCHAR(255) DEFAULT NULL COMMENT \'The error message for submissions which got an error during shadow importing.\'');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE queuetask CHANGE judgingid judgingid INT UNSIGNED DEFAULT NULL COMMENT \'All queuetasks with the same jobid belong together.\'');
$this->addSql('ALTER TABLE submission CHANGE import_error import_error VARCHAR(255) DEFAULT NULL COMMENT \'If this submission was imported during shadowing but had an error while doing so, the error message.\'');
}

public function isTransactional(): bool
{
return false;
}
}
42 changes: 42 additions & 0 deletions webapp/migrations/Version20231124124901.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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 Version20231124124901 extends AbstractMigration
{
public function getDescription(): string
{
return 'Sync name of index / foreign key for queuetask.judgingid with model';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE queuetask DROP FOREIGN KEY FK_45E85FF85D5FEA72');
$this->addSql('DROP INDEX jobid ON queuetask');
$this->addSql('CREATE INDEX judgingid ON queuetask (judgingid)');
$this->addSql('ALTER TABLE queuetask ADD CONSTRAINT FK_45E85FF85D5FEA72 FOREIGN KEY (judgingid) REFERENCES judging (judgingid) ON DELETE CASCADE');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE queuetask DROP FOREIGN KEY FK_45E85FF85D5FEA72');
$this->addSql('DROP INDEX judgingid ON queuetask');
$this->addSql('CREATE INDEX jobid ON queuetask (judgingid)');
$this->addSql('ALTER TABLE queuetask ADD CONSTRAINT FK_45E85FF85D5FEA72 FOREIGN KEY (judgingid) REFERENCES judging (judgingid) ON DELETE CASCADE');
}

public function isTransactional(): bool
{
return false;
}
}

0 comments on commit df78c81

Please sign in to comment.