Version20160930144400.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. error_log('Version20160930144400');
  19. $this->addSql('
  20. UPDATE track_e_hotspot h
  21. SET h.hotspot_answer_id = (
  22. SELECT qa.iid
  23. FROM c_quiz_answer qa
  24. WHERE h.c_id = qa.c_id AND
  25. h.hotspot_question_id = qa.question_id AND
  26. h.hotspot_answer_id = qa.id
  27. )
  28. ');
  29. $this->addSql('ALTER TABLE extra_field ADD visible_to_others TINYINT(1) DEFAULT 0, CHANGE visible visible_to_self TINYINT(1) DEFAULT 0');
  30. }
  31. /**
  32. * @param Schema $schema
  33. */
  34. public function down(Schema $schema)
  35. {
  36. $this->addSql('
  37. UPDATE track_e_hotspot h
  38. SET h.hotspot_answer_id = (
  39. SELECT qa.id
  40. FROM c_quiz_answer qa
  41. WHERE
  42. h.c_id = qa.c_id AND
  43. h.hotspot_question_id = qa.question_id AND
  44. h.hotspot_answer_id = qa.iid
  45. )
  46. ');
  47. }
  48. }