Version20160930144400.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. namespace Application\Migrations\Schema\V111;
  4. use Application\Migrations\AbstractMigrationChamilo;
  5. use Doctrine\DBAL\Schema\Schema;
  6. /**
  7. * Class Version20160930144400
  8. * Fix track_e_hotspot ussing c_quiz_answer iid
  9. * @package Application\Migrations\Schema\V111
  10. */
  11. class Version20160930144400 extends AbstractMigrationChamilo
  12. {
  13. /**
  14. * @param Schema $schema
  15. */
  16. public function up(Schema $schema)
  17. {
  18. $this->addSql('
  19. UPDATE track_e_hotspot h
  20. SET h.hotspot_answer_id = (
  21. SELECT qa.iid
  22. FROM c_quiz_answer qa
  23. WHERE h.c_id = qa.c_id AND
  24. h.hotspot_question_id = qa.question_id AND
  25. h.hotspot_answer_id = qa.id
  26. )
  27. ');
  28. $this->addSql('ALTER TABLE extra_field ADD visible_to_others TINYINT(1) DEFAULT 0, CHANGE visible visible_to_self TINYINT(1) DEFAULT 0');
  29. }
  30. /**
  31. * @param Schema $schema
  32. */
  33. public function down(Schema $schema)
  34. {
  35. $this->addSql('
  36. UPDATE track_e_hotspot h
  37. SET h.hotspot_answer_id = (
  38. SELECT qa.id
  39. FROM c_quiz_answer qa
  40. WHERE
  41. h.c_id = qa.c_id AND
  42. h.hotspot_question_id = qa.question_id AND
  43. h.hotspot_answer_id = qa.iid
  44. )
  45. ');
  46. }
  47. }