Version17000Date20190514105811.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 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 Version17000Date20190514105811 extends SimpleMigrationStep {
  14. /**
  15. * @param IOutput $output
  16. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  17. * @param array $options
  18. * @return ISchemaWrapper
  19. */
  20. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  21. /** @var ISchemaWrapper $schema */
  22. $schema = $schemaClosure();
  23. if (!$schema->hasTable('filecache_extended')) {
  24. $table = $schema->createTable('filecache_extended');
  25. $table->addColumn('fileid', Types::BIGINT, [
  26. 'notnull' => true,
  27. 'length' => 4,
  28. 'unsigned' => true,
  29. ]);
  30. $table->addColumn('metadata_etag', Types::STRING, [
  31. 'notnull' => false,
  32. 'length' => 40,
  33. ]);
  34. $table->addColumn('creation_time', Types::BIGINT, [
  35. 'notnull' => true,
  36. 'length' => 20,
  37. 'default' => 0,
  38. ]);
  39. $table->addColumn('upload_time', Types::BIGINT, [
  40. 'notnull' => true,
  41. 'length' => 20,
  42. 'default' => 0,
  43. ]);
  44. $table->setPrimaryKey(['fileid'], 'fce_pk');
  45. // $table->addUniqueIndex(['fileid'], 'fce_fileid_idx');
  46. $table->addIndex(['creation_time'], 'fce_ctime_idx');
  47. $table->addIndex(['upload_time'], 'fce_utime_idx');
  48. }
  49. return $schema;
  50. }
  51. }