1
0

Version13000Date20170705121758.php 2.7 KB

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