Version1006Date20180628111625.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\Migration;
  8. use OCP\DB\ISchemaWrapper;
  9. use OCP\DB\Types;
  10. use OCP\Migration\IOutput;
  11. use OCP\Migration\SimpleMigrationStep;
  12. class Version1006Date20180628111625 extends SimpleMigrationStep {
  13. /**
  14. * @param IOutput $output
  15. * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  16. * @param array $options
  17. * @return null|ISchemaWrapper
  18. */
  19. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  20. /** @var ISchemaWrapper $schema */
  21. $schema = $schemaClosure();
  22. if ($schema->hasTable('calendarchanges')) {
  23. $calendarChangesTable = $schema->getTable('calendarchanges');
  24. $calendarChangesTable->addColumn('calendartype', Types::INTEGER, [
  25. 'notnull' => true,
  26. 'default' => 0,
  27. ]);
  28. if ($calendarChangesTable->hasIndex('calendarid_synctoken')) {
  29. $calendarChangesTable->dropIndex('calendarid_synctoken');
  30. }
  31. $calendarChangesTable->addIndex(['calendarid', 'calendartype', 'synctoken'], 'calid_type_synctoken');
  32. }
  33. if ($schema->hasTable('calendarobjects')) {
  34. $calendarObjectsTable = $schema->getTable('calendarobjects');
  35. $calendarObjectsTable->addColumn('calendartype', Types::INTEGER, [
  36. 'notnull' => true,
  37. 'default' => 0,
  38. ]);
  39. if ($calendarObjectsTable->hasIndex('calobjects_index')) {
  40. $calendarObjectsTable->dropIndex('calobjects_index');
  41. }
  42. $calendarObjectsTable->addUniqueIndex(['calendarid', 'calendartype', 'uri'], 'calobjects_index');
  43. }
  44. if ($schema->hasTable('calendarobjects_props')) {
  45. $calendarObjectsPropsTable = $schema->getTable('calendarobjects_props');
  46. $calendarObjectsPropsTable->addColumn('calendartype', Types::INTEGER, [
  47. 'notnull' => true,
  48. 'default' => 0,
  49. ]);
  50. if ($calendarObjectsPropsTable->hasIndex('calendarobject_index')) {
  51. $calendarObjectsPropsTable->dropIndex('calendarobject_index');
  52. }
  53. if ($calendarObjectsPropsTable->hasIndex('calendarobject_name_index')) {
  54. $calendarObjectsPropsTable->dropIndex('calendarobject_name_index');
  55. }
  56. if ($calendarObjectsPropsTable->hasIndex('calendarobject_value_index')) {
  57. $calendarObjectsPropsTable->dropIndex('calendarobject_value_index');
  58. }
  59. $calendarObjectsPropsTable->addIndex(['objectid', 'calendartype'], 'calendarobject_index');
  60. $calendarObjectsPropsTable->addIndex(['name', 'calendartype'], 'calendarobject_name_index');
  61. $calendarObjectsPropsTable->addIndex(['value', 'calendartype'], 'calendarobject_value_index');
  62. $calendarObjectsPropsTable->addIndex(['calendarid', 'calendartype'], 'calendarobject_calid_index');
  63. }
  64. if ($schema->hasTable('calendarsubscriptions')) {
  65. $calendarSubscriptionsTable = $schema->getTable('calendarsubscriptions');
  66. $calendarSubscriptionsTable->addColumn('synctoken', 'integer', [
  67. 'notnull' => true,
  68. 'default' => 1,
  69. 'length' => 10,
  70. 'unsigned' => true,
  71. ]);
  72. }
  73. return $schema;
  74. }
  75. }