Version20150608104600.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. namespace Application\Migrations\Schema\V110;
  4. use Application\Migrations\AbstractMigrationChamilo;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\DBAL\Types\Type as TableColumnType;
  7. /**
  8. * Session date changes
  9. */
  10. class Version20150608104600 extends AbstractMigrationChamilo
  11. {
  12. /**
  13. * @param Schema $schema
  14. */
  15. public function up(Schema $schema)
  16. {
  17. if (!$schema->hasTable('extra_field_rel_tag')) {
  18. $extraFieldRelTag = $schema->createTable('extra_field_rel_tag');
  19. $extraFieldRelTag->addColumn(
  20. 'id',
  21. TableColumnType::INTEGER,
  22. ['unsigned' => true, 'autoincrement' => true, 'notnull' => true]
  23. );
  24. $extraFieldRelTag->addColumn(
  25. 'field_id',
  26. TableColumnType::INTEGER,
  27. ['unsigned' => true, 'notnull' => true]
  28. );
  29. $extraFieldRelTag->addColumn(
  30. 'item_id',
  31. TableColumnType::INTEGER,
  32. ['unsigned' => true, 'notnull' => true]
  33. );
  34. $extraFieldRelTag->addColumn(
  35. 'tag_id',
  36. TableColumnType::INTEGER,
  37. ['unsigned' => true, 'notnull' => true]
  38. );
  39. $extraFieldRelTag->setPrimaryKey(['id']);
  40. $extraFieldRelTag->addIndex(
  41. ['field_id'],
  42. 'idx_frt_field'
  43. );
  44. $extraFieldRelTag->addIndex(
  45. ['item_id'],
  46. 'idx_frt_item'
  47. );
  48. $extraFieldRelTag->addIndex(
  49. ['tag_id'],
  50. 'idx_frt_tag'
  51. );
  52. $extraFieldRelTag->addIndex(
  53. ['field_id', 'item_id', 'tag_id'],
  54. 'idx_frt_field_item_tag'
  55. );
  56. }
  57. }
  58. /**
  59. * @param Schema $schema
  60. */
  61. public function down(Schema $schema)
  62. {
  63. $schema->dropTable('extra_field_rel_tag');
  64. }
  65. }