1
0

Version28000Date20230616104802.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 llm_tasks table
  32. */
  33. class Version28000Date20230616104802 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('llm_tasks')) {
  44. $table = $schema->createTable('llm_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' => true,
  67. 'length' => 64,
  68. ]);
  69. $table->addColumn('app_id', Types::STRING, [
  70. 'notnull' => true,
  71. 'length' => 32,
  72. 'default' => '',
  73. ]);
  74. $table->addColumn('identifier', Types::STRING, [
  75. 'notnull' => true,
  76. 'length' => 255,
  77. 'default' => '',
  78. ]);
  79. $table->addColumn('last_updated', 'integer', [
  80. 'notnull' => false,
  81. 'length' => 4,
  82. 'default' => 0,
  83. 'unsigned' => true,
  84. ]);
  85. $table->setPrimaryKey(['id'], 'llm_tasks_id_index');
  86. $table->addUniqueIndex(['status', 'type'], 'llm_tasks_status_type');
  87. $table->addIndex(['last_updated'], 'llm_tasks_updated');
  88. return $schema;
  89. }
  90. return null;
  91. }
  92. }