1
0

Version30000Date20240708160048.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 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\Attributes\AddColumn;
  12. use OCP\Migration\Attributes\ColumnType;
  13. use OCP\Migration\IOutput;
  14. use OCP\Migration\SimpleMigrationStep;
  15. /**
  16. *
  17. */
  18. #[AddColumn(table: 'taskprocessing_tasks', name: 'scheduled_at', type: ColumnType::INTEGER)]
  19. #[AddColumn(table: 'taskprocessing_tasks', name: 'started_at', type: ColumnType::INTEGER)]
  20. #[AddColumn(table: 'taskprocessing_tasks', name: 'ended_at', type: ColumnType::INTEGER)]
  21. class Version30000Date20240708160048 extends SimpleMigrationStep {
  22. /**
  23. * @param IOutput $output
  24. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  25. * @param array $options
  26. * @return null|ISchemaWrapper
  27. */
  28. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  29. /** @var ISchemaWrapper $schema */
  30. $schema = $schemaClosure();
  31. if ($schema->hasTable('taskprocessing_tasks')) {
  32. $table = $schema->getTable('taskprocessing_tasks');
  33. if (!$table->hasColumn('scheduled_at')) {
  34. $table->addColumn('scheduled_at', Types::INTEGER, [
  35. 'notnull' => false,
  36. 'default' => null,
  37. 'unsigned' => true,
  38. ]);
  39. }
  40. if (!$table->hasColumn('started_at')) {
  41. $table->addColumn('started_at', Types::INTEGER, [
  42. 'notnull' => false,
  43. 'default' => null,
  44. 'unsigned' => true,
  45. ]);
  46. }
  47. if (!$table->hasColumn('ended_at')) {
  48. $table->addColumn('ended_at', Types::INTEGER, [
  49. 'notnull' => false,
  50. 'default' => null,
  51. 'unsigned' => true,
  52. ]);
  53. }
  54. return $schema;
  55. }
  56. return null;
  57. }
  58. }