1
0

Version1010Date20200630191755.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Julius Härtl <jus@bitgrid.net>
  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 OCA\FederatedFileSharing\Migration;
  27. use Closure;
  28. use OCP\DB\ISchemaWrapper;
  29. use OCP\DB\Types;
  30. use OCP\Migration\IOutput;
  31. use OCP\Migration\SimpleMigrationStep;
  32. class Version1010Date20200630191755 extends SimpleMigrationStep {
  33. /**
  34. * @param IOutput $output
  35. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  36. * @param array $options
  37. * @return null|ISchemaWrapper
  38. */
  39. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  40. /** @var ISchemaWrapper $schema */
  41. $schema = $schemaClosure();
  42. if (!$schema->hasTable('federated_reshares')) {
  43. $table = $schema->createTable('federated_reshares');
  44. $table->addColumn('share_id', Types::BIGINT, [
  45. 'notnull' => true,
  46. ]);
  47. $table->addColumn('remote_id', Types::STRING, [
  48. 'notnull' => false,
  49. 'length' => 255,
  50. 'default' => '',
  51. ]);
  52. $table->setPrimaryKey(['share_id'], 'federated_res_pk');
  53. // $table->addUniqueIndex(['share_id'], 'share_id_index');
  54. }
  55. return $schema;
  56. }
  57. }