You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Version1006Date20180628111625.php 3.6KB

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