Version1010Date20200630192842.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\User_LDAP\Migration;
  8. use Closure;
  9. use OCP\DB\ISchemaWrapper;
  10. use OCP\DB\Types;
  11. use OCP\Migration\IOutput;
  12. use OCP\Migration\SimpleMigrationStep;
  13. class Version1010Date20200630192842 extends SimpleMigrationStep {
  14. /**
  15. * @param IOutput $output
  16. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  17. * @param array $options
  18. * @return null|ISchemaWrapper
  19. */
  20. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  21. /** @var ISchemaWrapper $schema */
  22. $schema = $schemaClosure();
  23. if (!$schema->hasTable('ldap_user_mapping')) {
  24. $table = $schema->createTable('ldap_user_mapping');
  25. $table->addColumn('ldap_dn', Types::STRING, [
  26. 'notnull' => true,
  27. 'length' => 4000,
  28. 'default' => '',
  29. ]);
  30. $table->addColumn('owncloud_name', Types::STRING, [
  31. 'notnull' => true,
  32. 'length' => 64,
  33. 'default' => '',
  34. ]);
  35. $table->addColumn('directory_uuid', Types::STRING, [
  36. 'notnull' => true,
  37. 'length' => 255,
  38. 'default' => '',
  39. ]);
  40. $table->addColumn('ldap_dn_hash', Types::STRING, [
  41. 'notnull' => false,
  42. 'length' => 64,
  43. ]);
  44. $table->setPrimaryKey(['owncloud_name']);
  45. $table->addUniqueIndex(['ldap_dn_hash'], 'ldap_user_dn_hashes');
  46. $table->addUniqueIndex(['directory_uuid'], 'ldap_user_directory_uuid');
  47. }
  48. if (!$schema->hasTable('ldap_group_mapping')) {
  49. $table = $schema->createTable('ldap_group_mapping');
  50. $table->addColumn('ldap_dn', Types::STRING, [
  51. 'notnull' => true,
  52. 'length' => 4000,
  53. 'default' => '',
  54. ]);
  55. $table->addColumn('owncloud_name', Types::STRING, [
  56. 'notnull' => true,
  57. 'length' => 64,
  58. 'default' => '',
  59. ]);
  60. $table->addColumn('directory_uuid', Types::STRING, [
  61. 'notnull' => true,
  62. 'length' => 255,
  63. 'default' => '',
  64. ]);
  65. $table->addColumn('ldap_dn_hash', Types::STRING, [
  66. 'notnull' => false,
  67. 'length' => 64,
  68. ]);
  69. $table->setPrimaryKey(['owncloud_name']);
  70. $table->addUniqueIndex(['ldap_dn_hash'], 'ldap_group_dn_hashes');
  71. $table->addUniqueIndex(['directory_uuid'], 'ldap_group_directory_uuid');
  72. }
  73. if (!$schema->hasTable('ldap_group_members')) {
  74. $table = $schema->createTable('ldap_group_members');
  75. $table->addColumn('owncloudname', Types::STRING, [
  76. 'notnull' => true,
  77. 'length' => 255,
  78. 'default' => '',
  79. ]);
  80. $table->addColumn('owncloudusers', Types::TEXT, [
  81. 'notnull' => true,
  82. ]);
  83. $table->setPrimaryKey(['owncloudname']);
  84. }
  85. return $schema;
  86. }
  87. }