Version13000Date20170705121758.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
  4. *
  5. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OC\Core\Migrations;
  26. use Doctrine\DBAL\Types\Types;
  27. use OCP\DB\ISchemaWrapper;
  28. use OCP\Migration\IOutput;
  29. use OCP\Migration\SimpleMigrationStep;
  30. class Version13000Date20170705121758 extends SimpleMigrationStep {
  31. /**
  32. * @param IOutput $output
  33. * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  34. * @param array $options
  35. * @return null|ISchemaWrapper
  36. * @since 13.0.0
  37. */
  38. public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
  39. /** @var ISchemaWrapper $schema */
  40. $schema = $schemaClosure();
  41. if (!$schema->hasTable('personal_sections')) {
  42. $table = $schema->createTable('personal_sections');
  43. $table->addColumn('id', Types::STRING, [
  44. 'notnull' => false,
  45. 'length' => 64,
  46. ]);
  47. $table->addColumn('class', Types::STRING, [
  48. 'notnull' => true,
  49. 'length' => 255,
  50. ]);
  51. $table->addColumn('priority', Types::INTEGER, [
  52. 'notnull' => true,
  53. 'length' => 6,
  54. 'default' => 0,
  55. ]);
  56. $table->setPrimaryKey(['id'], 'personal_sections_id_index');
  57. $table->addUniqueIndex(['class'], 'personal_sections_class');
  58. }
  59. if (!$schema->hasTable('personal_settings')) {
  60. $table = $schema->createTable('personal_settings');
  61. $table->addColumn('id', Types::INTEGER, [
  62. 'autoincrement' => true,
  63. 'notnull' => true,
  64. 'length' => 20,
  65. ]);
  66. $table->addColumn('class', Types::STRING, [
  67. 'notnull' => true,
  68. 'length' => 255,
  69. ]);
  70. $table->addColumn('section', Types::STRING, [
  71. 'notnull' => false,
  72. 'length' => 64,
  73. ]);
  74. $table->addColumn('priority', Types::INTEGER, [
  75. 'notnull' => true,
  76. 'length' => 6,
  77. 'default' => 0,
  78. ]);
  79. $table->setPrimaryKey(['id'], 'personal_settings_id_index');
  80. $table->addUniqueIndex(['class'], 'personal_settings_class');
  81. $table->addIndex(['section'], 'personal_settings_section');
  82. }
  83. return $schema;
  84. }
  85. }