1
0

Version1006Date20180628111625.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2018 Georg Ehrke <oc.list@georgehrke.com>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  8. * @author Georg Ehrke <oc.list@georgehrke.com>
  9. * @author Joas Schilling <coding@schilljs.com>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. *
  12. * @license GNU AGPL version 3 or any later version
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License as
  16. * published by the Free Software Foundation, either version 3 of the
  17. * License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. *
  27. */
  28. namespace OCA\DAV\Migration;
  29. use OCP\DB\ISchemaWrapper;
  30. use OCP\DB\Types;
  31. use OCP\Migration\IOutput;
  32. use OCP\Migration\SimpleMigrationStep;
  33. class Version1006Date20180628111625 extends SimpleMigrationStep {
  34. /**
  35. * @param IOutput $output
  36. * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  37. * @param array $options
  38. * @return null|ISchemaWrapper
  39. */
  40. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  41. /** @var ISchemaWrapper $schema */
  42. $schema = $schemaClosure();
  43. if ($schema->hasTable('calendarchanges')) {
  44. $calendarChangesTable = $schema->getTable('calendarchanges');
  45. $calendarChangesTable->addColumn('calendartype', Types::INTEGER, [
  46. 'notnull' => true,
  47. 'default' => 0,
  48. ]);
  49. if ($calendarChangesTable->hasIndex('calendarid_synctoken')) {
  50. $calendarChangesTable->dropIndex('calendarid_synctoken');
  51. }
  52. $calendarChangesTable->addIndex(['calendarid', 'calendartype', 'synctoken'], 'calid_type_synctoken');
  53. }
  54. if ($schema->hasTable('calendarobjects')) {
  55. $calendarObjectsTable = $schema->getTable('calendarobjects');
  56. $calendarObjectsTable->addColumn('calendartype', Types::INTEGER, [
  57. 'notnull' => true,
  58. 'default' => 0,
  59. ]);
  60. if ($calendarObjectsTable->hasIndex('calobjects_index')) {
  61. $calendarObjectsTable->dropIndex('calobjects_index');
  62. }
  63. $calendarObjectsTable->addUniqueIndex(['calendarid', 'calendartype', 'uri'], 'calobjects_index');
  64. }
  65. if ($schema->hasTable('calendarobjects_props')) {
  66. $calendarObjectsPropsTable = $schema->getTable('calendarobjects_props');
  67. $calendarObjectsPropsTable->addColumn('calendartype', Types::INTEGER, [
  68. 'notnull' => true,
  69. 'default' => 0,
  70. ]);
  71. if ($calendarObjectsPropsTable->hasIndex('calendarobject_index')) {
  72. $calendarObjectsPropsTable->dropIndex('calendarobject_index');
  73. }
  74. if ($calendarObjectsPropsTable->hasIndex('calendarobject_name_index')) {
  75. $calendarObjectsPropsTable->dropIndex('calendarobject_name_index');
  76. }
  77. if ($calendarObjectsPropsTable->hasIndex('calendarobject_value_index')) {
  78. $calendarObjectsPropsTable->dropIndex('calendarobject_value_index');
  79. }
  80. $calendarObjectsPropsTable->addIndex(['objectid', 'calendartype'], 'calendarobject_index');
  81. $calendarObjectsPropsTable->addIndex(['name', 'calendartype'], 'calendarobject_name_index');
  82. $calendarObjectsPropsTable->addIndex(['value', 'calendartype'], 'calendarobject_value_index');
  83. $calendarObjectsPropsTable->addIndex(['calendarid', 'calendartype'], 'calendarobject_calid_index');
  84. }
  85. if ($schema->hasTable('calendarsubscriptions')) {
  86. $calendarSubscriptionsTable = $schema->getTable('calendarsubscriptions');
  87. $calendarSubscriptionsTable->addColumn('synctoken', 'integer', [
  88. 'notnull' => true,
  89. 'default' => 1,
  90. 'length' => 10,
  91. 'unsigned' => true,
  92. ]);
  93. }
  94. return $schema;
  95. }
  96. }