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