Version13000Date20170705121758.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OC\Core\Migrations;
  7. use OCP\DB\ISchemaWrapper;
  8. use OCP\DB\Types;
  9. use OCP\Migration\IOutput;
  10. use OCP\Migration\SimpleMigrationStep;
  11. class Version13000Date20170705121758 extends SimpleMigrationStep {
  12. /**
  13. * @param IOutput $output
  14. * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  15. * @param array $options
  16. * @return null|ISchemaWrapper
  17. * @since 13.0.0
  18. */
  19. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  20. /** @var ISchemaWrapper $schema */
  21. $schema = $schemaClosure();
  22. if (!$schema->hasTable('personal_sections')) {
  23. $table = $schema->createTable('personal_sections');
  24. $table->addColumn('id', Types::STRING, [
  25. 'notnull' => false,
  26. 'length' => 64,
  27. ]);
  28. $table->addColumn('class', Types::STRING, [
  29. 'notnull' => true,
  30. 'length' => 255,
  31. ]);
  32. $table->addColumn('priority', Types::INTEGER, [
  33. 'notnull' => true,
  34. 'length' => 6,
  35. 'default' => 0,
  36. ]);
  37. $table->setPrimaryKey(['id'], 'personal_sections_id_index');
  38. $table->addUniqueIndex(['class'], 'personal_sections_class');
  39. }
  40. if (!$schema->hasTable('personal_settings')) {
  41. $table = $schema->createTable('personal_settings');
  42. $table->addColumn('id', Types::INTEGER, [
  43. 'autoincrement' => true,
  44. 'notnull' => true,
  45. 'length' => 20,
  46. ]);
  47. $table->addColumn('class', Types::STRING, [
  48. 'notnull' => true,
  49. 'length' => 255,
  50. ]);
  51. $table->addColumn('section', Types::STRING, [
  52. 'notnull' => false,
  53. 'length' => 64,
  54. ]);
  55. $table->addColumn('priority', Types::INTEGER, [
  56. 'notnull' => true,
  57. 'length' => 6,
  58. 'default' => 0,
  59. ]);
  60. $table->setPrimaryKey(['id'], 'personal_settings_id_index');
  61. $table->addUniqueIndex(['class'], 'personal_settings_class');
  62. $table->addIndex(['section'], 'personal_settings_section');
  63. }
  64. return $schema;
  65. }
  66. }