Version30000Date20240429122720.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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\IOutput;
  12. use OCP\Migration\SimpleMigrationStep;
  13. /**
  14. *
  15. */
  16. class Version30000Date20240429122720 extends SimpleMigrationStep {
  17. /**
  18. * @param IOutput $output
  19. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  20. * @param array $options
  21. * @return null|ISchemaWrapper
  22. */
  23. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  24. /** @var ISchemaWrapper $schema */
  25. $schema = $schemaClosure();
  26. if (!$schema->hasTable('taskprocessing_tasks')) {
  27. $table = $schema->createTable('taskprocessing_tasks');
  28. $table->addColumn('id', Types::BIGINT, [
  29. 'notnull' => true,
  30. 'length' => 64,
  31. 'autoincrement' => true,
  32. ]);
  33. $table->addColumn('type', Types::STRING, [
  34. 'notnull' => true,
  35. 'length' => 255,
  36. ]);
  37. $table->addColumn('input', Types::TEXT, [
  38. 'notnull' => true,
  39. ]);
  40. $table->addColumn('output', Types::TEXT, [
  41. 'notnull' => false,
  42. ]);
  43. $table->addColumn('status', Types::INTEGER, [
  44. 'notnull' => false,
  45. 'length' => 6,
  46. 'default' => 0,
  47. ]);
  48. $table->addColumn('user_id', Types::STRING, [
  49. 'notnull' => false,
  50. 'length' => 64,
  51. ]);
  52. $table->addColumn('app_id', Types::STRING, [
  53. 'notnull' => true,
  54. 'length' => 32,
  55. 'default' => '',
  56. ]);
  57. $table->addColumn('custom_id', Types::STRING, [
  58. 'notnull' => false,
  59. 'length' => 255,
  60. 'default' => '',
  61. ]);
  62. $table->addColumn('last_updated', Types::INTEGER, [
  63. 'notnull' => false,
  64. 'length' => 4,
  65. 'default' => 0,
  66. 'unsigned' => true,
  67. ]);
  68. $table->addColumn('completion_expected_at', Types::DATETIME, [
  69. 'notnull' => false,
  70. ]);
  71. $table->addColumn('progress', Types::FLOAT, [
  72. 'notnull' => false,
  73. 'default' => 0,
  74. ]);
  75. $table->addColumn('error_message', Types::STRING, [
  76. 'notnull' => false,
  77. 'length' => 255,
  78. ]);
  79. $table->setPrimaryKey(['id'], 'taskp_tasks_id_index');
  80. $table->addIndex(['status', 'type'], 'taskp_tasks_status_type');
  81. $table->addIndex(['last_updated'], 'taskp_tasks_updated');
  82. $table->addIndex(['user_id', 'app_id', 'custom_id'], 'taskp_tasks_uid_appid_cid');
  83. return $schema;
  84. }
  85. return null;
  86. }
  87. }