Version0001Date20200602134824.php 2.8 KB

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