@@ -28,8 +28,6 @@ public function up(Schema $schema): void
28
28
public function down (Schema $ schema ): void
29
29
{
30
30
$ this ->dropKeys ();
31
-
32
- // Reinstate the 'restrict' keys.
33
31
$ this ->addKeys (false );
34
32
}
35
33
@@ -41,20 +39,24 @@ public function dropKeys(): void
41
39
$ this ->addSql ('ALTER TABLE judging_run DROP CONSTRAINT FK_29A6E6E13CBA64F2 ' );
42
40
$ this ->addSql ('ALTER TABLE judging_run DROP CONSTRAINT judging_run_ibfk_1 ' );
43
41
$ this ->addSql ('ALTER TABLE judgetask DROP CONSTRAINT judgetask_ibfk_1 ' );
42
+ $ this ->addSql ('ALTER TABLE submission DROP FOREIGN KEY FK_DB055AF3F132696E ' );
44
43
}
45
44
46
- public function addKeys (bool $ suffix ): void
45
+ public function addKeys (bool $ isUp ): void
47
46
{
48
47
// foreign-keys that are related to judgehosts are set to null so that no data is lost.
49
- $ cascadeClause = $ suffix ? 'ON DELETE CASCADE ' : '' ;
50
- $ nullClause = $ suffix ? 'ON DELETE SET NULL ' : '' ;
48
+ $ cascadeClause = $ isUp ? 'ON DELETE CASCADE ' : '' ;
49
+ $ nullClause = $ isUp ? 'ON DELETE SET NULL ' : '' ;
51
50
52
51
$ this ->addSql ('ALTER TABLE version ADD CONSTRAINT `FK_BF1CD3C32271845` FOREIGN KEY (`langid`) REFERENCES `language` (`langid`) ' . $ cascadeClause );
53
52
$ this ->addSql ('ALTER TABLE version ADD CONSTRAINT `FK_BF1CD3C3E0E4FC3E` FOREIGN KEY (`judgehostid`) REFERENCES `judgehost` (`judgehostid`) ' . $ nullClause );
54
53
$ this ->addSql ('ALTER TABLE judging_run ADD CONSTRAINT `FK_29A6E6E13CBA64F2` FOREIGN KEY (`judgetaskid`) REFERENCES `judgetask` (`judgetaskid`) ' . $ cascadeClause );
55
54
$ this ->addSql ('ALTER TABLE judging_run ADD CONSTRAINT `judging_run_ibfk_1` FOREIGN KEY (`testcaseid`) REFERENCES `testcase` (`testcaseid`) ' . $ cascadeClause );
56
55
$ this ->addSql ('ALTER TABLE judgetask ADD CONSTRAINT `judgetask_ibfk_1` FOREIGN KEY (`judgehostid`) REFERENCES `judgehost` (`judgehostid`) ' . $ nullClause );
57
56
$ this ->addSql ('ALTER TABLE debug_package ADD CONSTRAINT `FK_9E17399BE0E4FC3E` FOREIGN KEY (`judgehostid`) REFERENCES `judgehost` (`judgehostid`) ' . $ nullClause );
57
+
58
+ $ clause = $ isUp ? 'ON DELETE SET NULL ' : 'ON DELETE CASCADE ' ;
59
+ $ this ->addSql ('ALTER TABLE submission ADD CONSTRAINT FK_DB055AF3F132696E FOREIGN KEY (userid) REFERENCES user (userid) ' . $ clause );
58
60
}
59
61
60
62
public function isTransactional (): bool
0 commit comments