diff --git a/app/Migrations/Schema/V110/Version110.php b/app/Migrations/Schema/V110/Version110.php index 15edf18e81..63fb10ff0d 100644 --- a/app/Migrations/Schema/V110/Version110.php +++ b/app/Migrations/Schema/V110/Version110.php @@ -24,7 +24,7 @@ class Version110 extends AbstractMigrationChamilo $this->addSql("ALTER TABLE session_rel_course ENGINE=InnoDB"); $this->addSql("ALTER TABLE session_rel_course_rel_user ENGINE=InnoDB"); $this->addSql("ALTER TABLE session_rel_user ENGINE=InnoDB"); - $this->addSql("UPDATE session SET session.id_coach = (SELECT user_id FROM admin LIMIT 1) WHERE id_coach NOT IN (SELECT user_id FROM user)"); + $this->addSql("UPDATE session SET session.id_coach = (SELECT u.id FROM admin a INNER JOIN user u ON (u.id = a.user_id AND u.active = 1) LIMIT 1) WHERE id_coach NOT IN (SELECT user_id FROM user)"); } /** diff --git a/app/Migrations/Schema/V110/Version20150603181728.php b/app/Migrations/Schema/V110/Version20150603181728.php index 85a0d8ed47..c0bc175c3f 100644 --- a/app/Migrations/Schema/V110/Version20150603181728.php +++ b/app/Migrations/Schema/V110/Version20150603181728.php @@ -61,7 +61,7 @@ class Version20150603181728 extends AbstractMigrationChamilo // Sometimes the user was deleted but we need to keep the document. // Taking first admin - $this->addSql("UPDATE c_item_property SET insert_user_id = (SELECT user_id FROM admin LIMIT 1) WHERE insert_user_id IS NOT NULL AND insert_user_id <> 0 AND insert_user_id NOT IN (SELECT id FROM user)"); + $this->addSql("UPDATE c_item_property SET insert_user_id = (SELECT u.id FROM admin a INNER JOIN user u ON (u.id = a.user_id AND u.active = 1) LIMIT 1) WHERE insert_user_id IS NOT NULL AND insert_user_id <> 0 AND insert_user_id NOT IN (SELECT id FROM user)"); // Remove inconsistencies about non-existing users $this->addSql("DELETE FROM c_item_property WHERE c_id NOT IN (SELECT id FROM course)");