You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Version28000Date20230906104802.php 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 text2image_tasks table
  15. */
  16. class Version28000Date20230906104802 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. if (!$schema->hasTable('text2image_tasks')) {
  27. $table = $schema->createTable('text2image_tasks');
  28. $table->addColumn('id', Types::BIGINT, [
  29. 'notnull' => true,
  30. 'length' => 64,
  31. 'autoincrement' => true,
  32. ]);
  33. $table->addColumn('input', Types::TEXT, [
  34. 'notnull' => true,
  35. ]);
  36. $table->addColumn('status', Types::INTEGER, [
  37. 'notnull' => false,
  38. 'length' => 6,
  39. 'default' => 0,
  40. ]);
  41. $table->addColumn('number_of_images', Types::INTEGER, [
  42. 'notnull' => true,
  43. 'default' => 1,
  44. ]);
  45. $table->addColumn('user_id', Types::STRING, [
  46. 'notnull' => false,
  47. 'length' => 64,
  48. ]);
  49. $table->addColumn('app_id', Types::STRING, [
  50. 'notnull' => true,
  51. 'length' => 32,
  52. 'default' => '',
  53. ]);
  54. $table->addColumn('identifier', Types::STRING, [
  55. 'notnull' => false,
  56. 'length' => 255,
  57. 'default' => '',
  58. ]);
  59. $table->addColumn('last_updated', Types::DATETIME, [
  60. 'notnull' => false,
  61. ]);
  62. $table->addColumn('completion_expected_at', Types::DATETIME, [
  63. 'notnull' => false,
  64. ]);
  65. $table->setPrimaryKey(['id'], 't2i_tasks_id_index');
  66. $table->addIndex(['last_updated'], 't2i_tasks_updated');
  67. $table->addIndex(['status'], 't2i_tasks_status');
  68. $table->addIndex(['user_id', 'app_id', 'identifier'], 't2i_tasks_uid_appid_ident');
  69. return $schema;
  70. }
  71. return null;
  72. }
  73. }