Version20160706145000.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. use Doctrine\DBAL\Types\Type;
  7. /**
  8. * Class Version20160706145000
  9. * Add tag extra field for skills
  10. * @package Application\Migrations\Schema\V111
  11. */
  12. class Version20160706145000 extends AbstractMigrationChamilo
  13. {
  14. /**
  15. * @param Schema $schema
  16. * @throws \Doctrine\DBAL\DBALException
  17. * @throws \Doctrine\DBAL\Schema\SchemaException
  18. */
  19. public function up(Schema $schema)
  20. {
  21. $connection = $this->connection;
  22. $sql = "SELECT id FROM extra_field WHERE variable = 'tags'";
  23. $result = $connection->executeQuery($sql)->fetchAll();
  24. if (empty($result)) {
  25. $this->addSql("INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) VALUES (8, 10, 'tags', 'Tags', 1, 1, NOW())");
  26. }
  27. }
  28. /**
  29. * @param Schema $schema
  30. * @throws \Doctrine\DBAL\DBALException
  31. * @throws \Doctrine\DBAL\Schema\SchemaException
  32. */
  33. public function down(Schema $schema)
  34. {
  35. $this->addSql("DELETE FROM extra_field WHERE extra_field_type = 8 AND field_type = 10 AND variable = 'tags'");
  36. }
  37. }