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.

Version0001Date20200602134824.php 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2020, Georg Ehrke
  5. *
  6. * @author Georg Ehrke <oc.list@georgehrke.com>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCA\UserStatus\Migration;
  24. use Doctrine\DBAL\Types\Types;
  25. use OCP\DB\ISchemaWrapper;
  26. use OCP\Migration\IOutput;
  27. use OCP\Migration\SimpleMigrationStep;
  28. /**
  29. * Class Version0001Date20200602134824
  30. *
  31. * @package OCA\UserStatus\Migration
  32. */
  33. class Version0001Date20200602134824 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. * @since 20.0.0
  40. */
  41. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  42. /** @var ISchemaWrapper $schema */
  43. $schema = $schemaClosure();
  44. $statusTable = $schema->createTable('user_status');
  45. $statusTable->addColumn('id', Types::BIGINT, [
  46. 'autoincrement' => true,
  47. 'notnull' => true,
  48. 'length' => 20,
  49. 'unsigned' => true,
  50. ]);
  51. $statusTable->addColumn('user_id', Types::STRING, [
  52. 'notnull' => true,
  53. 'length' => 255,
  54. ]);
  55. $statusTable->addColumn('status', Types::STRING, [
  56. 'notnull' => true,
  57. 'length' => 255,
  58. ]);
  59. $statusTable->addColumn('status_timestamp', Types::INTEGER, [
  60. 'notnull' => true,
  61. 'length' => 11,
  62. 'unsigned' => true,
  63. ]);
  64. $statusTable->addColumn('is_user_defined', Types::BOOLEAN, [
  65. 'notnull' => true,
  66. ]);
  67. $statusTable->addColumn('message_id', Types::STRING, [
  68. 'notnull' => false,
  69. 'length' => 255,
  70. ]);
  71. $statusTable->addColumn('custom_icon', Types::STRING, [
  72. 'notnull' => false,
  73. 'length' => 255,
  74. ]);
  75. $statusTable->addColumn('custom_message', Types::TEXT, [
  76. 'notnull' => false,
  77. ]);
  78. $statusTable->addColumn('clear_at', Types::INTEGER, [
  79. 'notnull' => false,
  80. 'length' => 11,
  81. 'unsigned' => true,
  82. ]);
  83. $statusTable->setPrimaryKey(['id']);
  84. $statusTable->addUniqueIndex(['user_id'], 'user_status_uid_ix');
  85. $statusTable->addIndex(['clear_at'], 'user_status_clr_ix');
  86. return $schema;
  87. }
  88. }