1
0

Version30000Date20240429122720.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2024 Marcel Klehr <mklehr@gmx.net>
  5. *
  6. * @author Marcel Klehr <mklehr@gmx.net>
  7. *
  8. * @license AGPL-3.0-or-later
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OC\Core\Migrations;
  25. use Closure;
  26. use OCP\DB\ISchemaWrapper;
  27. use OCP\DB\Types;
  28. use OCP\Migration\IOutput;
  29. use OCP\Migration\SimpleMigrationStep;
  30. /**
  31. *
  32. */
  33. class Version30000Date20240429122720 extends SimpleMigrationStep {
  34. /**
  35. * @param IOutput $output
  36. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  37. * @param array $options
  38. * @return null|ISchemaWrapper
  39. */
  40. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  41. /** @var ISchemaWrapper $schema */
  42. $schema = $schemaClosure();
  43. if (!$schema->hasTable('taskprocessing_tasks')) {
  44. $table = $schema->createTable('taskprocessing_tasks');
  45. $table->addColumn('id', Types::BIGINT, [
  46. 'notnull' => true,
  47. 'length' => 64,
  48. 'autoincrement' => true,
  49. ]);
  50. $table->addColumn('type', Types::STRING, [
  51. 'notnull' => true,
  52. 'length' => 255,
  53. ]);
  54. $table->addColumn('input', Types::TEXT, [
  55. 'notnull' => true,
  56. ]);
  57. $table->addColumn('output', Types::TEXT, [
  58. 'notnull' => false,
  59. ]);
  60. $table->addColumn('status', Types::INTEGER, [
  61. 'notnull' => false,
  62. 'length' => 6,
  63. 'default' => 0,
  64. ]);
  65. $table->addColumn('user_id', Types::STRING, [
  66. 'notnull' => false,
  67. 'length' => 64,
  68. ]);
  69. $table->addColumn('app_id', Types::STRING, [
  70. 'notnull' => true,
  71. 'length' => 32,
  72. 'default' => '',
  73. ]);
  74. $table->addColumn('custom_id', Types::STRING, [
  75. 'notnull' => false,
  76. 'length' => 255,
  77. 'default' => '',
  78. ]);
  79. $table->addColumn('last_updated', Types::INTEGER, [
  80. 'notnull' => false,
  81. 'length' => 4,
  82. 'default' => 0,
  83. 'unsigned' => true,
  84. ]);
  85. $table->addColumn('completion_expected_at', Types::DATETIME, [
  86. 'notnull' => false,
  87. ]);
  88. $table->addColumn('progress', Types::FLOAT, [
  89. 'notnull' => false,
  90. 'default' => 0,
  91. ]);
  92. $table->addColumn('error_message', Types::STRING, [
  93. 'notnull' => false,
  94. 'length' => 255,
  95. ]);
  96. $table->setPrimaryKey(['id'], 'taskp_tasks_id_index');
  97. $table->addIndex(['status', 'type'], 'taskp_tasks_status_type');
  98. $table->addIndex(['last_updated'], 'taskp_tasks_updated');
  99. $table->addIndex(['user_id', 'app_id', 'custom_id'], 'taskp_tasks_uid_appid_cid');
  100. return $schema;
  101. }
  102. return null;
  103. }
  104. }