@@ -28,8 +28,6 @@ public function up(Schema $schema): void
2828 public function down (Schema $ schema ): void
2929 {
3030 $ this ->dropKeys ();
31-
32- // Reinstate the 'restrict' keys.
3331 $ this ->addKeys (false );
3432 }
3533
@@ -41,20 +39,24 @@ public function dropKeys(): void
4139 $ this ->addSql ('ALTER TABLE judging_run DROP CONSTRAINT FK_29A6E6E13CBA64F2 ' );
4240 $ this ->addSql ('ALTER TABLE judging_run DROP CONSTRAINT judging_run_ibfk_1 ' );
4341 $ this ->addSql ('ALTER TABLE judgetask DROP CONSTRAINT judgetask_ibfk_1 ' );
42+ $ this ->addSql ('ALTER TABLE submission DROP FOREIGN KEY FK_DB055AF3F132696E ' );
4443 }
4544
46- public function addKeys (bool $ suffix ): void
45+ public function addKeys (bool $ isUp ): void
4746 {
4847 // 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 ' : '' ;
5150
5251 $ this ->addSql ('ALTER TABLE version ADD CONSTRAINT `FK_BF1CD3C32271845` FOREIGN KEY (`langid`) REFERENCES `language` (`langid`) ' . $ cascadeClause );
5352 $ this ->addSql ('ALTER TABLE version ADD CONSTRAINT `FK_BF1CD3C3E0E4FC3E` FOREIGN KEY (`judgehostid`) REFERENCES `judgehost` (`judgehostid`) ' . $ nullClause );
5453 $ this ->addSql ('ALTER TABLE judging_run ADD CONSTRAINT `FK_29A6E6E13CBA64F2` FOREIGN KEY (`judgetaskid`) REFERENCES `judgetask` (`judgetaskid`) ' . $ cascadeClause );
5554 $ this ->addSql ('ALTER TABLE judging_run ADD CONSTRAINT `judging_run_ibfk_1` FOREIGN KEY (`testcaseid`) REFERENCES `testcase` (`testcaseid`) ' . $ cascadeClause );
5655 $ this ->addSql ('ALTER TABLE judgetask ADD CONSTRAINT `judgetask_ibfk_1` FOREIGN KEY (`judgehostid`) REFERENCES `judgehost` (`judgehostid`) ' . $ nullClause );
5756 $ 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 );
5860 }
5961
6062 public function isTransactional (): bool
0 commit comments