Version20150505142900.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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;
  7. /**
  8. * Class Version20150505142900
  9. *
  10. * @package Application\Migrations\Schema\V110
  11. */
  12. class Version20150505142900 extends AbstractMigrationChamilo
  13. {
  14. /**
  15. * @param Schema $schema
  16. *
  17. * @throws \Doctrine\DBAL\Schema\SchemaException
  18. */
  19. public function up(Schema $schema)
  20. {
  21. // Create table for video chat
  22. if (!$schema->hasTable('chat_video')) {
  23. $chatVideoTable = $schema->createTable('chat_video');
  24. $chatVideoTable->addColumn(
  25. 'id',
  26. Type::INTEGER,
  27. ['autoincrement' => true, 'notnull' => true]
  28. );
  29. $chatVideoTable->addColumn(
  30. 'from_user',
  31. Type::INTEGER,
  32. ['notnull' => true]
  33. );
  34. $chatVideoTable->addColumn(
  35. 'to_user',
  36. Type::INTEGER,
  37. ['notnull' => true]
  38. );
  39. $chatVideoTable->addColumn(
  40. 'room_name',
  41. Type::STRING,
  42. ['length' => 255, 'notnull' => true]
  43. );
  44. $chatVideoTable->addColumn(
  45. 'datetime',
  46. Type::DATETIME,
  47. ['notnull' => true]
  48. );
  49. $chatVideoTable->setPrimaryKey(['id']);
  50. $chatVideoTable->addIndex(
  51. ['from_user'],
  52. 'idx_chat_video_from_user'
  53. );
  54. $chatVideoTable->addIndex(['to_user'], 'idx_chat_video_to_user');
  55. $chatVideoTable->addIndex(
  56. ['from_user', 'to_user'],
  57. 'idx_chat_video_users'
  58. );
  59. $chatVideoTable->addIndex(
  60. ['room_name'],
  61. 'idx_chat_video_room_name'
  62. );
  63. }
  64. }
  65. /**
  66. * We don't allow downgrades yet
  67. * @param Schema $schema
  68. */
  69. public function down(Schema $schema)
  70. {
  71. $schema->dropTable('chat_video');
  72. }
  73. }