1
0

Version24000Date20220404230027.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright 2022 Carl Schwan <carl@carlschwan.eu>
  5. *
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace OC\Core\Migrations;
  22. use Closure;
  23. use OCP\DB\ISchemaWrapper;
  24. use OCP\DB\Types;
  25. use OCP\Migration\IOutput;
  26. use OCP\Migration\SimpleMigrationStep;
  27. /**
  28. * Add oc_file_metadata table
  29. * @see \OC\Metadata\FileMetadata
  30. */
  31. class Version24000Date20220404230027 extends SimpleMigrationStep {
  32. /**
  33. * @param IOutput $output
  34. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  35. * @param array $options
  36. * @return null|ISchemaWrapper
  37. */
  38. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  39. /** @var ISchemaWrapper $schema */
  40. $schema = $schemaClosure();
  41. if (!$schema->hasTable('file_metadata')) {
  42. $table = $schema->createTable('file_metadata');
  43. $table->addColumn('id', Types::BIGINT, [
  44. 'notnull' => true,
  45. ]);
  46. $table->addColumn('group_name', Types::STRING, [
  47. 'notnull' => true,
  48. 'length' => 50,
  49. ]);
  50. $table->addColumn('value', Types::TEXT, [
  51. 'notnull' => false,
  52. 'default' => '',
  53. ]);
  54. $table->setPrimaryKey(['id', 'group_name'], 'file_metadata_idx');
  55. return $schema;
  56. }
  57. return null;
  58. }
  59. }