1
0

Version27000Date20230309104325.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Core\Migrations;
  8. use Closure;
  9. use OCP\DB\ISchemaWrapper;
  10. use OCP\DB\Types;
  11. use OCP\IDBConnection;
  12. use OCP\Migration\IOutput;
  13. use OCP\Migration\SimpleMigrationStep;
  14. /**
  15. * Migrate oc_file_metadata.metadata as JSON type to oc_file_metadata.value a STRING type
  16. * @see \OC\Metadata\FileMetadata
  17. */
  18. class Version27000Date20230309104325 extends SimpleMigrationStep {
  19. public function __construct(
  20. private IDBConnection $connection,
  21. ) {
  22. }
  23. /**
  24. * @param IOutput $output
  25. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  26. * @param array $options
  27. * @return null|ISchemaWrapper
  28. */
  29. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  30. // /** @var ISchemaWrapper $schema */
  31. // $schema = $schemaClosure();
  32. // $metadataTable = $schema->getTable('file_metadata');
  33. // if ($metadataTable->hasColumn('value')) {
  34. // return null;
  35. // }
  36. // $metadataTable->addColumn('value', Types::TEXT, [
  37. // 'notnull' => false,
  38. // 'default' => '',
  39. // ]);
  40. // return $schema;
  41. return null;
  42. }
  43. /**
  44. * @param IOutput $output
  45. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  46. * @param array $options
  47. * @return void
  48. */
  49. public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
  50. /** @var ISchemaWrapper $schema */
  51. // $schema = $schemaClosure();
  52. // $metadataTable = $schema->getTable('file_metadata');
  53. // if (!$metadataTable->hasColumn('metadata')) {
  54. // return;
  55. // }
  56. // $this->connection
  57. // ->getQueryBuilder()
  58. // ->update('file_metadata')
  59. // ->set('value', 'metadata')
  60. // ->executeStatement();
  61. }
  62. }