Version20160603113100.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. $languageTable = $schema->getTable('language');
  22. $languageTable
  23. ->getColumn('parent_id')
  24. ->setType(Type::getType(Type::INTEGER))
  25. ->setNotnull(false);
  26. $languageTable->addForeignKeyConstraint('language', ['parent_id'], ['id'], [], 'language_parent');
  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. $languageTable = $schema->getTable('language');
  36. $languageTable->removeForeignKey('language_parent');
  37. $languageTable
  38. ->getColumn('parent_id')
  39. ->setType(Type::getType(Type::BOOLEAN))
  40. ->setNotnull(false);
  41. }
  42. }