1
0

Version1005Date20180530124431.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * @copyright 2017 Georg Ehrke <oc.list@georgehrke.com>
  4. *
  5. * @author Georg Ehrke <oc.list@georgehrke.com>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCA\DAV\Migration;
  26. use Doctrine\DBAL\Types\Type;
  27. use OCP\DB\ISchemaWrapper;
  28. use OCP\Migration\IOutput;
  29. use OCP\Migration\SimpleMigrationStep;
  30. class Version1005Date20180530124431 extends SimpleMigrationStep {
  31. /**
  32. * @param IOutput $output
  33. * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  34. * @param array $options
  35. * @return null|ISchemaWrapper
  36. * @since 13.0.0
  37. */
  38. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  39. /** @var ISchemaWrapper $schema */
  40. $schema = $schemaClosure();
  41. $types = ['resources', 'rooms'];
  42. foreach($types as $type) {
  43. if (!$schema->hasTable('calendar_' . $type)) {
  44. $table = $schema->createTable('calendar_' . $type);
  45. $table->addColumn('id', Type::BIGINT, [
  46. 'autoincrement' => true,
  47. 'notnull' => true,
  48. 'length' => 11,
  49. 'unsigned' => true,
  50. ]);
  51. $table->addColumn('backend_id', Type::STRING, [
  52. 'notnull' => false,
  53. 'length' => 64,
  54. ]);
  55. $table->addColumn('resource_id', Type::STRING, [
  56. 'notnull' => false,
  57. 'length' => 64,
  58. ]);
  59. $table->addColumn('email', Type::STRING, [
  60. 'notnull' => false,
  61. 'length' => 255,
  62. ]);
  63. $table->addColumn('displayname', Type::STRING, [
  64. 'notnull' => false,
  65. 'length' => 255,
  66. ]);
  67. $table->addColumn('group_restrictions', Type::STRING, [
  68. 'notnull' => false,
  69. 'length' => 4000,
  70. ]);
  71. $table->setPrimaryKey(['id']);
  72. $table->addIndex(['backend_id', 'resource_id'], 'calendar_' . $type . '_bkdrsc');
  73. $table->addIndex(['email'], 'calendar_' . $type . '_email');
  74. $table->addIndex(['displayname'], 'calendar_' . $type . '_name');
  75. }
  76. }
  77. return $schema;
  78. }
  79. }