forked from DOMjudge/domjudge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split submission file source code from submission files.
Similar to DOMjudge#2241 this gets rid of the only other partial query.
- Loading branch information
1 parent
e187de8
commit a93f189
Showing
12 changed files
with
156 additions
and
27 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,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 Version20231124162457 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Split submission file contents from submission files'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('CREATE TABLE submission_file_content (submitfileid INT UNSIGNED NOT NULL COMMENT \'Submission file ID\', sourcecode LONGBLOB NOT NULL COMMENT \'Submission file sourcecode(DC2Type:blobtext)\', PRIMARY KEY(submitfileid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'Stores contents of submission files\' '); | ||
$this->addSql('ALTER TABLE submission_file_content ADD CONSTRAINT FK_5846B4F7834A5B68 FOREIGN KEY (submitfileid) REFERENCES submission_file (submitfileid) ON DELETE CASCADE'); | ||
$this->addSql('INSERT INTO submission_file_content (submitfileid, sourcecode) SELECT submitfileid, sourcecode FROM submission_file'); | ||
$this->addSql('ALTER TABLE submission_file DROP sourcecode'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE submission_file ADD sourcecode LONGBLOB NOT NULL COMMENT \'Full source code(DC2Type:blobtext)\''); | ||
$this->addSql('UPDATE submission_file INNER JOIN submission_file_content USING (submitfileid) SET submission_file.sourcecode = submission_file_content.sourcecode'); | ||
$this->addSql('ALTER TABLE submission_file_content DROP FOREIGN KEY FK_5846B4F7834A5B68'); | ||
$this->addSql('DROP TABLE submission_file_content'); | ||
} | ||
|
||
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
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
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
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
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
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,51 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace App\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
#[ORM\Entity] | ||
#[ORM\Table(options: [ | ||
'collation' => 'utf8mb4_unicode_ci', | ||
'charset' => 'utf8mb4', | ||
'comment' => 'Stores contents of submission files', | ||
])] | ||
class SubmissionFileContent | ||
{ | ||
/** | ||
* We use a ManyToOne instead of a OneToOne here, because otherwise the | ||
* reverse of this relation will always be loaded. See the commit message of commit | ||
* 9e421f96691ec67ed62767fe465a6d8751edd884 for a more elaborate explanation. | ||
*/ | ||
#[ORM\Id] | ||
#[ORM\ManyToOne(inversedBy: 'content')] | ||
#[ORM\JoinColumn(name: 'submitfileid', referencedColumnName: 'submitfileid', onDelete: 'CASCADE')] | ||
private SubmissionFile $submissionFile; | ||
|
||
#[ORM\Column(type: 'blobtext', options: ['comment' => 'Submission file sourcecode'])] | ||
private string $sourcecode; | ||
|
||
public function getSubmissionFile(): SubmissionFile | ||
{ | ||
return $this->submissionFile; | ||
} | ||
|
||
public function setSubmissionFile(SubmissionFile $submissionFile): self | ||
{ | ||
$this->submissionFile = $submissionFile; | ||
|
||
return $this; | ||
} | ||
|
||
public function getSourcecode(): string | ||
{ | ||
return $this->sourcecode; | ||
} | ||
|
||
public function setSourcecode(string $sourcecode): self | ||
{ | ||
$this->sourcecode = $sourcecode; | ||
|
||
return $this; | ||
} | ||
} |
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
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
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
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
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