Version20160706182000.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 Version20160706182000
  9. * Add new table to save user visibility on courses in the catalogue
  10. * @package Application\Migrations\Schema\V111
  11. */
  12. class Version20160706182000 extends AbstractMigrationChamilo
  13. {
  14. /**
  15. * @param Schema $schema
  16. *
  17. * @throws \Doctrine\DBAL\DBALException
  18. * @throws \Doctrine\DBAL\Schema\SchemaException
  19. */
  20. public function up(Schema $schema)
  21. {
  22. $this->addSql(
  23. 'CREATE TABLE course_rel_user_catalogue (id int NOT NULL AUTO_INCREMENT, user_id int DEFAULT NULL, c_id int DEFAULT NULL, visible int NOT NULL, PRIMARY KEY (id), KEY (user_id), KEY (c_id), CONSTRAINT FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE, CONSTRAINT FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
  24. );
  25. }
  26. /**
  27. * @param Schema $schema
  28. *
  29. * @throws \Doctrine\DBAL\DBALException
  30. * @throws \Doctrine\DBAL\Schema\SchemaException
  31. */
  32. public function down(Schema $schema)
  33. {
  34. $this->addSql(
  35. 'DROP TABLE course_rel_user_catalogue'
  36. );
  37. }
  38. }