1
0

Version1024Date20211221144219.php 1.5 KB

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