1
0

Version11301Date20191205150729.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Files\Migration;
  8. use Closure;
  9. use OCP\DB\ISchemaWrapper;
  10. use OCP\Migration\IOutput;
  11. use OCP\Migration\SimpleMigrationStep;
  12. class Version11301Date20191205150729 extends SimpleMigrationStep {
  13. /**
  14. * @param IOutput $output
  15. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  16. * @param array $options
  17. * @return null|ISchemaWrapper
  18. */
  19. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  20. /** @var ISchemaWrapper $schema */
  21. $schema = $schemaClosure();
  22. $table = $schema->createTable('user_transfer_owner');
  23. $table->addColumn('id', 'bigint', [
  24. 'autoincrement' => true,
  25. 'notnull' => true,
  26. 'length' => 20,
  27. 'unsigned' => true,
  28. ]);
  29. $table->addColumn('source_user', 'string', [
  30. 'notnull' => true,
  31. 'length' => 64,
  32. ]);
  33. $table->addColumn('target_user', 'string', [
  34. 'notnull' => true,
  35. 'length' => 64,
  36. ]);
  37. $table->addColumn('file_id', 'bigint', [
  38. 'notnull' => true,
  39. 'length' => 20,
  40. ]);
  41. $table->addColumn('node_name', 'string', [
  42. 'notnull' => true,
  43. 'length' => 255,
  44. ]);
  45. $table->setPrimaryKey(['id']);
  46. // Quite radical, we just assume no one updates cross beta with a pending request.
  47. // Do not try this at home
  48. if ($schema->hasTable('user_transfer_ownership')) {
  49. $schema->dropTable('user_transfer_ownership');
  50. }
  51. return $schema;
  52. }
  53. }