Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/model/entity/ExerciseFileLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
* I.e., when Assignment is created from Exercise, the links are copied (immediately) as well.
* The link of an exercise may be updated, but the link of an assignment is immutable.
* @ORM\Entity
* @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(columns={"key", "exercise_id"}),
* @ORM\UniqueConstraint(columns={"key", "assignment_id"})})
* @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(columns={"key", "exercise_id"})})
*
* Note: technically, there should be also unique constraint on (key, assignment_id); however, it causes more problems
* than it solves. During sync operation, the assignment-related links are cleared and re-filled. Since the Doctrine
* performs inserts before deletes, and we do not want to flush in the middle, it causes unique constraint violation.
*/
class ExerciseFileLink implements JsonSerializable
{
Expand Down
31 changes: 31 additions & 0 deletions migrations/Version20251214183529.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20251214183529 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_1187F7758A90ABA9D19302F8 ON exercise_file_link');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE UNIQUE INDEX UNIQ_1187F7758A90ABA9D19302F8 ON exercise_file_link (`key`, assignment_id)');
}
}