Version1005Date20180530124431.php 2.7 KB

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