選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Version240000Date20220404230027.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 Version240000Date20220404230027 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::INTEGER, [
  44. 'notnull' => true,
  45. ]);
  46. $table->addColumn('group_name', Types::STRING, [
  47. 'notnull' => true,
  48. 'length' => 50,
  49. ]);
  50. $table->addColumn('metadata', Types::JSON, [
  51. 'notnull' => true,
  52. ]);
  53. $table->setPrimaryKey(['id', 'group_name'], 'file_metadata_idx');
  54. }
  55. return $schema;
  56. }
  57. }