Version20171213092400.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 Version20171213092400
  8. *
  9. * Fix some missing queries for migration from 1.10 to 1.11 (GH#2214)
  10. * These are minor changes caused by the move from static SQL to ORM entities
  11. *
  12. * @package Application\Migrations\Schema\V111
  13. */
  14. class Version20171213092400 extends AbstractMigrationChamilo
  15. {
  16. /**
  17. * @param Schema $schema
  18. */
  19. public function up(Schema $schema)
  20. {
  21. error_log('Version20171213092400');
  22. $table = $schema->getTable('extra_field_values');
  23. $hasIndex = $table->hasIndex('idx_efv_fiii');
  24. if (!$hasIndex) {
  25. $this->addSql('CREATE INDEX idx_efv_fiii ON extra_field_values (field_id, item_id)');
  26. }
  27. $this->addSql('ALTER TABLE language CHANGE parent_id parent_id INT DEFAULT NULL');
  28. $table = $schema->getTable('c_quiz_answer');
  29. $hasIndex = $table->hasIndex('idx_cqa_q');
  30. if (!$hasIndex) {
  31. $this->addSql('CREATE INDEX idx_cqa_q ON c_quiz_answer (question_id)');
  32. }
  33. $this->addSql('ALTER TABLE c_quiz CHANGE start_time start_time DATETIME DEFAULT NULL');
  34. $this->addSql('ALTER TABLE c_quiz CHANGE end_time end_time DATETIME DEFAULT NULL');
  35. }
  36. /**
  37. * @param Schema $schema
  38. */
  39. public function down(Schema $schema)
  40. {
  41. $table = $schema->getTable('c_quiz_answer');
  42. $hasIndex = $table->hasIndex('idx_cqa_q');
  43. if ($hasIndex) {
  44. $this->addSql('DROP INDEX idx_cqa_q ON c_quiz_answer');
  45. }
  46. $table = $schema->getTable('language');
  47. $this->addSql('ALTER TABLE language CHANGE parent_id parent_id TINYINT DEFAULT NULL');
  48. $table = $schema->getTable('extra_field_values');
  49. $hasIndex = $table->hasIndex('idx_efv_fiii');
  50. if ($hasIndex) {
  51. $this->addSql('DROP INDEX idx_efv_fiii ON extra_field_values');
  52. }
  53. }
  54. }