From cbb4ec7de92bd3e546bc150b03c3db904f6ecca7 Mon Sep 17 00:00:00 2001 From: NicoDucou Date: Thu, 27 Jul 2023 21:20:46 +0200 Subject: [PATCH] Migrations: Fixing problem when gradebook_category parent_id does not exist -refs https://github.com/chamilo/chamilo-lms/wiki/Clean-up-choices-for-v1-to-v2#gradebook_categoryparent_id BT#20864 --- src/CoreBundle/Migrations/Schema/V200/Version20181025064351.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20181025064351.php b/src/CoreBundle/Migrations/Schema/V200/Version20181025064351.php index b1f37b172c..5b6cb98f7c 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20181025064351.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20181025064351.php @@ -72,6 +72,7 @@ class Version20181025064351 extends AbstractMigrationChamilo $this->addSql('UPDATE gradebook_category SET parent_id = NULL WHERE parent_id = 0'); $this->addSql('DELETE FROM gradebook_category WHERE session_id IS NOT NULL AND session_id NOT IN (SELECT id FROM session)'); + $this->addSql('DELETE FROM gradebook_category WHERE parent_id IS NOT NULL AND parent_id NOT IN (SELECT id FROM gradebook_category)'); if (false === $table->hasForeignKey('FK_96A4C705727ACA70')) { $this->addSql('ALTER TABLE gradebook_category ADD CONSTRAINT FK_96A4C705727ACA70 FOREIGN KEY (parent_id) REFERENCES gradebook_category (id) ON DELETE CASCADE');