Version21000Date20201202095923.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 OC\Core\Migrations;
  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 Version21000Date20201202095923 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): ?ISchemaWrapper {
  21. /** @var ISchemaWrapper $schema */
  22. $schema = $schemaClosure();
  23. if (!$schema->hasTable('accounts_data')) {
  24. $table = $schema->createTable('accounts_data');
  25. $table->addColumn('id', Types::BIGINT, [
  26. 'autoincrement' => true,
  27. 'notnull' => true,
  28. 'length' => 20,
  29. ]);
  30. $table->addColumn('uid', Types::STRING, [
  31. 'notnull' => true,
  32. 'length' => 64,
  33. ]);
  34. $table->addColumn('name', Types::STRING, [
  35. 'notnull' => true,
  36. 'length' => 64,
  37. ]);
  38. $table->addColumn('value', Types::STRING, [
  39. 'notnull' => false,
  40. 'length' => 255,
  41. 'default' => '',
  42. ]);
  43. $table->setPrimaryKey(['id']);
  44. $table->addIndex(['uid'], 'accounts_data_uid');
  45. $table->addIndex(['name'], 'accounts_data_name');
  46. $table->addIndex(['value'], 'accounts_data_value');
  47. return $schema;
  48. }
  49. return null;
  50. }
  51. }