1
0

Version1006Date20180628111625.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2018 Georg Ehrke <oc.list@georgehrke.com>
  5. *
  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 Version1006Date20180628111625 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. */
  38. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  39. /** @var ISchemaWrapper $schema */
  40. $schema = $schemaClosure();
  41. if ($schema->hasTable('calendarchanges')) {
  42. $calendarChangesTable = $schema->getTable('calendarchanges');
  43. $calendarChangesTable->addColumn('calendartype', Type::INTEGER, [
  44. 'notnull' => true,
  45. 'default' => 0,
  46. ]);
  47. if ($calendarChangesTable->hasIndex('calendarid_synctoken')) {
  48. $calendarChangesTable->dropIndex('calendarid_synctoken');
  49. }
  50. $calendarChangesTable->addIndex(['calendarid', 'calendartype', 'synctoken'], 'calid_type_synctoken');
  51. }
  52. if ($schema->hasTable('calendarobjects')) {
  53. $calendarObjectsTable = $schema->getTable('calendarobjects');
  54. $calendarObjectsTable->addColumn('calendartype', Type::INTEGER, [
  55. 'notnull' => true,
  56. 'default' => 0,
  57. ]);
  58. if ($calendarObjectsTable->hasIndex('calobjects_index')) {
  59. $calendarObjectsTable->dropIndex('calobjects_index');
  60. }
  61. $calendarObjectsTable->addUniqueIndex(['calendarid', 'calendartype', 'uri'], 'calobjects_index');
  62. }
  63. if ($schema->hasTable('calendarobjects_props')) {
  64. $calendarObjectsPropsTable = $schema->getTable('calendarobjects_props');
  65. $calendarObjectsPropsTable->addColumn('calendartype', Type::INTEGER, [
  66. 'notnull' => true,
  67. 'default' => 0,
  68. ]);
  69. if ($calendarObjectsPropsTable->hasIndex('calendarobject_index')) {
  70. $calendarObjectsPropsTable->dropIndex('calendarobject_index');
  71. }
  72. if ($calendarObjectsPropsTable->hasIndex('calendarobject_name_index')) {
  73. $calendarObjectsPropsTable->dropIndex('calendarobject_name_index');
  74. }
  75. if ($calendarObjectsPropsTable->hasIndex('calendarobject_value_index')) {
  76. $calendarObjectsPropsTable->dropIndex('calendarobject_value_index');
  77. }
  78. $calendarObjectsPropsTable->addIndex(['objectid', 'calendartype'], 'calendarobject_index');
  79. $calendarObjectsPropsTable->addIndex(['name', 'calendartype'], 'calendarobject_name_index');
  80. $calendarObjectsPropsTable->addIndex(['value', 'calendartype'], 'calendarobject_value_index');
  81. $calendarObjectsPropsTable->addIndex(['calendarid', 'calendartype'], 'calendarobject_calid_index');
  82. }
  83. if ($schema->hasTable('calendarsubscriptions')) {
  84. $calendarSubscriptionsTable = $schema->getTable('calendarsubscriptions');
  85. $calendarSubscriptionsTable->addColumn('synctoken', 'integer', [
  86. 'notnull' => true,
  87. 'default' => 1,
  88. 'length' => 10,
  89. 'unsigned' => true,
  90. ]);
  91. }
  92. return $schema;
  93. }
  94. }