Version1024Date20211221144219.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\Migration;
  8. use Closure;
  9. use Doctrine\DBAL\Schema\SchemaException;
  10. use OCA\DAV\DAV\CustomPropertiesBackend;
  11. use OCP\DB\ISchemaWrapper;
  12. use OCP\DB\Types;
  13. use OCP\Migration\IOutput;
  14. use OCP\Migration\SimpleMigrationStep;
  15. /**
  16. * Auto-generated migration step: Please modify to your needs!
  17. */
  18. class Version1024Date20211221144219 extends SimpleMigrationStep {
  19. /**
  20. * @param IOutput $output
  21. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  22. * @param array $options
  23. */
  24. public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
  25. }
  26. /**
  27. * @param IOutput $output
  28. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  29. * @param array $options
  30. * @return null|ISchemaWrapper
  31. * @throws SchemaException
  32. */
  33. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  34. /** @var ISchemaWrapper $schema */
  35. $schema = $schemaClosure();
  36. $propertiesTable = $schema->getTable('properties');
  37. if ($propertiesTable->hasColumn('valuetype')) {
  38. return null;
  39. }
  40. $propertiesTable->addColumn('valuetype', Types::SMALLINT, [
  41. 'notnull' => false,
  42. 'default' => CustomPropertiesBackend::PROPERTY_TYPE_STRING
  43. ]);
  44. return $schema;
  45. }
  46. /**
  47. * @param IOutput $output
  48. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  49. * @param array $options
  50. */
  51. public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
  52. }
  53. }