Skip to content

Commit 71592f1

Browse files
committed
Fix migration on c_item_property - refs #8331
1 parent ae43d26 commit 71592f1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/Migrations/Schema/V110/Version20150603181728.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ public function up(Schema $schema)
5959
$this->addSql("UPDATE c_item_property SET session_id = NULL WHERE session_id NOT IN (SELECT id FROM session)");
6060

6161
// Remove inconsistencies about non-existing courses
62-
$this->addSql("DELETE FROM c_item_property WHERE c_id NOT IN (SELECT user_id FROM user)");
62+
$this->addSql("DELETE FROM c_item_property WHERE c_id NOT IN (SELECT id FROM course)");
6363
// Remove inconsistencies about non-existing users
6464
$this->addSql("DELETE FROM course_rel_user WHERE user_id NOT IN (SELECT user_id FROM user)");
6565

6666
$this->addSql("DELETE FROM c_item_property WHERE c_id NOT IN (SELECT id FROM course)");
67-
$this->addSql("DELETE FROM c_item_property WHERE to_group_id NOT IN (SELECT id FROM c_group_info)");
67+
$this->addSql("UPDATE c_item_property SET to_group_id = NULL WHERE to_group_id = 0");
68+
$this->addSql("DELETE FROM c_item_property WHERE to_group_id IS NOT NULL AND to_group_id NOT IN (SELECT id FROM c_group_info)");
6869

6970
$this->addSql('UPDATE c_item_property cip SET cip.to_group_id = (SELECT cgi.iid FROM c_group_info cgi WHERE cgi.c_id = cip.c_id AND cgi.id = cip.to_group_id)');
7071

0 commit comments

Comments
 (0)