diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20180928172830.php b/src/CoreBundle/Migrations/Schema/V200/Version20180928172830.php index d906cd0e4d..6032558560 100644 --- a/src/CoreBundle/Migrations/Schema/V200/Version20180928172830.php +++ b/src/CoreBundle/Migrations/Schema/V200/Version20180928172830.php @@ -61,11 +61,14 @@ class Version20180928172830 extends AbstractMigrationChamilo $this->addSql('ALTER TABLE c_tool DROP custom_icon'); } - if (false === $table->hasColumn('resource_node_id')) { - $this->addSql('ALTER TABLE c_tool ADD resource_node_id BIGINT DEFAULT NULL'); - $this->addSql('UPDATE c_tool SET session_id = NULL WHERE session_id = 0'); + $this->addSql('UPDATE c_tool SET session_id = NULL WHERE session_id = 0'); + + // Delete c_tool not registered in tool. @todo migrate BBB/LP/mobidico plugins + $this->addSql('DELETE FROM c_tool WHERE name NOT IN (SELECT name FROM tool)'); + $this->addSql('UPDATE c_tool SET tool_id = (SELECT id FROM tool WHERE name = c_tool.name) WHERE tool_id IS NOT NULL'); - $this->addSql('UPDATE c_tool SET tool_id = (SELECT id FROM tool WHERE name = c_tool.name) WHERE tool_id IS NOT NULL'); + if (!$table->hasColumn('resource_node_id')) { + $this->addSql('ALTER TABLE c_tool ADD resource_node_id BIGINT DEFAULT NULL'); // @todo remove/move LP/Link shortcuts. $this->addSql('DELETE FROM c_tool WHERE tool_id = 0 OR tool_id IS NULL');