Version28000Date20230728104802.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /**
  14. * Introduce textprocessing_tasks table
  15. */
  16. class Version28000Date20230728104802 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. $changed = false;
  27. if ($schema->hasTable('llm_tasks')) {
  28. $schema->dropTable('llm_tasks');
  29. $changed = true;
  30. }
  31. if (!$schema->hasTable('textprocessing_tasks')) {
  32. $table = $schema->createTable('textprocessing_tasks');
  33. $table->addColumn('id', Types::BIGINT, [
  34. 'notnull' => true,
  35. 'length' => 64,
  36. 'autoincrement' => true,
  37. ]);
  38. $table->addColumn('type', Types::STRING, [
  39. 'notnull' => true,
  40. 'length' => 255,
  41. ]);
  42. $table->addColumn('input', Types::TEXT, [
  43. 'notnull' => true,
  44. ]);
  45. $table->addColumn('output', Types::TEXT, [
  46. 'notnull' => false,
  47. ]);
  48. $table->addColumn('status', Types::INTEGER, [
  49. 'notnull' => false,
  50. 'length' => 6,
  51. 'default' => 0,
  52. ]);
  53. $table->addColumn('user_id', Types::STRING, [
  54. 'notnull' => true,
  55. 'length' => 64,
  56. ]);
  57. $table->addColumn('app_id', Types::STRING, [
  58. 'notnull' => true,
  59. 'length' => 32,
  60. 'default' => '',
  61. ]);
  62. $table->addColumn('identifier', Types::STRING, [
  63. 'notnull' => true,
  64. 'length' => 255,
  65. 'default' => '',
  66. ]);
  67. $table->addColumn('last_updated', Types::INTEGER, [
  68. 'notnull' => false,
  69. 'length' => 4,
  70. 'default' => 0,
  71. 'unsigned' => true,
  72. ]);
  73. $table->setPrimaryKey(['id'], 'tp_tasks_id_index');
  74. $table->addIndex(['last_updated'], 'tp_tasks_updated');
  75. $table->addIndex(['status', 'type'], 'tp_tasks_status_type_nonunique');
  76. $changed = true;
  77. }
  78. if ($changed) {
  79. return $schema;
  80. }
  81. return null;
  82. }
  83. }