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.

Version13000Date20170705121758.php 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  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 OC\Core\Migrations;
  27. use OCP\DB\Types;
  28. use OCP\DB\ISchemaWrapper;
  29. use OCP\Migration\IOutput;
  30. use OCP\Migration\SimpleMigrationStep;
  31. class Version13000Date20170705121758 extends SimpleMigrationStep {
  32. /**
  33. * @param IOutput $output
  34. * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  35. * @param array $options
  36. * @return null|ISchemaWrapper
  37. * @since 13.0.0
  38. */
  39. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  40. /** @var ISchemaWrapper $schema */
  41. $schema = $schemaClosure();
  42. if (!$schema->hasTable('personal_sections')) {
  43. $table = $schema->createTable('personal_sections');
  44. $table->addColumn('id', Types::STRING, [
  45. 'notnull' => false,
  46. 'length' => 64,
  47. ]);
  48. $table->addColumn('class', Types::STRING, [
  49. 'notnull' => true,
  50. 'length' => 255,
  51. ]);
  52. $table->addColumn('priority', Types::INTEGER, [
  53. 'notnull' => true,
  54. 'length' => 6,
  55. 'default' => 0,
  56. ]);
  57. $table->setPrimaryKey(['id'], 'personal_sections_id_index');
  58. $table->addUniqueIndex(['class'], 'personal_sections_class');
  59. }
  60. if (!$schema->hasTable('personal_settings')) {
  61. $table = $schema->createTable('personal_settings');
  62. $table->addColumn('id', Types::INTEGER, [
  63. 'autoincrement' => true,
  64. 'notnull' => true,
  65. 'length' => 20,
  66. ]);
  67. $table->addColumn('class', Types::STRING, [
  68. 'notnull' => true,
  69. 'length' => 255,
  70. ]);
  71. $table->addColumn('section', Types::STRING, [
  72. 'notnull' => false,
  73. 'length' => 64,
  74. ]);
  75. $table->addColumn('priority', Types::INTEGER, [
  76. 'notnull' => true,
  77. 'length' => 6,
  78. 'default' => 0,
  79. ]);
  80. $table->setPrimaryKey(['id'], 'personal_settings_id_index');
  81. $table->addUniqueIndex(['class'], 'personal_settings_class');
  82. $table->addIndex(['section'], 'personal_settings_section');
  83. }
  84. return $schema;
  85. }
  86. }