Version0001Date20200602134824.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\UserStatus\Migration;
  8. use OCP\DB\ISchemaWrapper;
  9. use OCP\DB\Types;
  10. use OCP\Migration\IOutput;
  11. use OCP\Migration\SimpleMigrationStep;
  12. /**
  13. * Class Version0001Date20200602134824
  14. *
  15. * @package OCA\UserStatus\Migration
  16. */
  17. class Version0001Date20200602134824 extends SimpleMigrationStep {
  18. /**
  19. * @param IOutput $output
  20. * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  21. * @param array $options
  22. * @return null|ISchemaWrapper
  23. * @since 20.0.0
  24. */
  25. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  26. /** @var ISchemaWrapper $schema */
  27. $schema = $schemaClosure();
  28. $statusTable = $schema->createTable('user_status');
  29. $statusTable->addColumn('id', Types::BIGINT, [
  30. 'autoincrement' => true,
  31. 'notnull' => true,
  32. 'length' => 20,
  33. 'unsigned' => true,
  34. ]);
  35. $statusTable->addColumn('user_id', Types::STRING, [
  36. 'notnull' => true,
  37. 'length' => 255,
  38. ]);
  39. $statusTable->addColumn('status', Types::STRING, [
  40. 'notnull' => true,
  41. 'length' => 255,
  42. ]);
  43. $statusTable->addColumn('status_timestamp', Types::INTEGER, [
  44. 'notnull' => true,
  45. 'length' => 11,
  46. 'unsigned' => true,
  47. ]);
  48. $statusTable->addColumn('is_user_defined', Types::BOOLEAN, [
  49. 'notnull' => false,
  50. ]);
  51. $statusTable->addColumn('message_id', Types::STRING, [
  52. 'notnull' => false,
  53. 'length' => 255,
  54. ]);
  55. $statusTable->addColumn('custom_icon', Types::STRING, [
  56. 'notnull' => false,
  57. 'length' => 255,
  58. ]);
  59. $statusTable->addColumn('custom_message', Types::TEXT, [
  60. 'notnull' => false,
  61. ]);
  62. $statusTable->addColumn('clear_at', Types::INTEGER, [
  63. 'notnull' => false,
  64. 'length' => 11,
  65. 'unsigned' => true,
  66. ]);
  67. $statusTable->setPrimaryKey(['id']);
  68. $statusTable->addUniqueIndex(['user_id'], 'user_status_uid_ix');
  69. $statusTable->addIndex(['clear_at'], 'user_status_clr_ix');
  70. return $schema;
  71. }
  72. }