1
0

Version28000Date20230728104802.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net>
  5. *
  6. * @author Marcel Klehr <mklehr@gmx.net>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (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 Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero 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. * Introduce textprocessing_tasks table
  32. */
  33. class Version28000Date20230728104802 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. $changed = false;
  44. if ($schema->hasTable('llm_tasks')) {
  45. $schema->dropTable('llm_tasks');
  46. $changed = true;
  47. }
  48. if (!$schema->hasTable('textprocessing_tasks')) {
  49. $table = $schema->createTable('textprocessing_tasks');
  50. $table->addColumn('id', Types::BIGINT, [
  51. 'notnull' => true,
  52. 'length' => 64,
  53. 'autoincrement' => true,
  54. ]);
  55. $table->addColumn('type', Types::STRING, [
  56. 'notnull' => true,
  57. 'length' => 255,
  58. ]);
  59. $table->addColumn('input', Types::TEXT, [
  60. 'notnull' => true,
  61. ]);
  62. $table->addColumn('output', Types::TEXT, [
  63. 'notnull' => false,
  64. ]);
  65. $table->addColumn('status', Types::INTEGER, [
  66. 'notnull' => false,
  67. 'length' => 6,
  68. 'default' => 0,
  69. ]);
  70. $table->addColumn('user_id', Types::STRING, [
  71. 'notnull' => true,
  72. 'length' => 64,
  73. ]);
  74. $table->addColumn('app_id', Types::STRING, [
  75. 'notnull' => true,
  76. 'length' => 32,
  77. 'default' => '',
  78. ]);
  79. $table->addColumn('identifier', Types::STRING, [
  80. 'notnull' => true,
  81. 'length' => 255,
  82. 'default' => '',
  83. ]);
  84. $table->addColumn('last_updated', Types::INTEGER, [
  85. 'notnull' => false,
  86. 'length' => 4,
  87. 'default' => 0,
  88. 'unsigned' => true,
  89. ]);
  90. $table->setPrimaryKey(['id'], 'tp_tasks_id_index');
  91. $table->addIndex(['last_updated'], 'tp_tasks_updated');
  92. $table->addIndex(['status', 'type'], 'tp_tasks_status_type_nonunique');
  93. $changed = true;
  94. }
  95. if ($changed) {
  96. return $schema;
  97. }
  98. return null;
  99. }
  100. }