1
0

Version29000Date20231213104850.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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\Migration\IOutput;
  12. use OCP\Migration\SimpleMigrationStep;
  13. class Version29000Date20231213104850 extends SimpleMigrationStep {
  14. /**
  15. * @param IOutput $output
  16. * @param Closure(): ISchemaWrapper $schemaClosure
  17. * @param array $options
  18. * @return null|ISchemaWrapper
  19. */
  20. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  21. /** @var ISchemaWrapper $schema */
  22. $schema = $schemaClosure();
  23. $table = $schema->getTable('comments');
  24. $modified = false;
  25. if (!$table->hasColumn('reference_id')) {
  26. $modified = true;
  27. $table->addColumn('reference_id', Types::STRING, [
  28. 'notnull' => false,
  29. 'length' => 64,
  30. ]);
  31. }
  32. if (!$table->hasColumn('meta_data')) {
  33. $modified = true;
  34. $table->addColumn('meta_data', Types::TEXT, [
  35. 'notnull' => false,
  36. 'default' => '',
  37. ]);
  38. }
  39. return $modified ? $schema : null;
  40. }
  41. }