Version20160603113100.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 Version20160603113100
  9. * Add association mapping for Language class
  10. * @package Application\Migrations\Schema\V111
  11. */
  12. class Version20160603113100 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. $this->addSql('ALTER TABLE language MODIFY id INT');
  22. $this->addSql('ALTER TABLE language MODIFY parent_id INT');
  23. $this->addSql('ALTER TABLE language ADD CONSTRAINT language_parent FOREIGN KEY (parent_id) REFERENCES language (id)');
  24. }
  25. /**
  26. * @param Schema $schema
  27. * @throws \Doctrine\DBAL\DBALException
  28. * @throws \Doctrine\DBAL\Schema\SchemaException
  29. */
  30. public function down(Schema $schema)
  31. {
  32. $languageTable = $schema->getTable('language');
  33. $languageTable->removeForeignKey('language_parent');
  34. $languageTable
  35. ->getColumn('parent_id')
  36. ->setType(Type::getType(Type::BOOLEAN))
  37. ->setNotnull(false);
  38. }
  39. }