1
0

Version28000Date20230906104802.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 text2image_tasks table
  32. */
  33. class Version28000Date20230906104802 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('text2image_tasks')) {
  44. $table = $schema->createTable('text2image_tasks');
  45. $table->addColumn('id', Types::BIGINT, [
  46. 'notnull' => true,
  47. 'length' => 64,
  48. 'autoincrement' => true,
  49. ]);
  50. $table->addColumn('input', Types::TEXT, [
  51. 'notnull' => true,
  52. ]);
  53. $table->addColumn('status', Types::INTEGER, [
  54. 'notnull' => false,
  55. 'length' => 6,
  56. 'default' => 0,
  57. ]);
  58. $table->addColumn('number_of_images', Types::INTEGER, [
  59. 'notnull' => true,
  60. 'default' => 1,
  61. ]);
  62. $table->addColumn('user_id', Types::STRING, [
  63. 'notnull' => false,
  64. 'length' => 64,
  65. ]);
  66. $table->addColumn('app_id', Types::STRING, [
  67. 'notnull' => true,
  68. 'length' => 32,
  69. 'default' => '',
  70. ]);
  71. $table->addColumn('identifier', Types::STRING, [
  72. 'notnull' => false,
  73. 'length' => 255,
  74. 'default' => '',
  75. ]);
  76. $table->addColumn('last_updated', Types::DATETIME, [
  77. 'notnull' => false,
  78. ]);
  79. $table->addColumn('completion_expected_at', Types::DATETIME, [
  80. 'notnull' => false,
  81. ]);
  82. $table->setPrimaryKey(['id'], 't2i_tasks_id_index');
  83. $table->addIndex(['last_updated'], 't2i_tasks_updated');
  84. $table->addIndex(['status'], 't2i_tasks_status');
  85. $table->addIndex(['user_id', 'app_id', 'identifier'], 't2i_tasks_uid_appid_ident');
  86. return $schema;
  87. }
  88. return null;
  89. }
  90. }