Version13000Date20170705121758.php 2.7 KB

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