1
0

Version17000Date20190514105811.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2019 Morris Jobke <hey@morrisjobke.de>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. *
  12. * @license GNU AGPL version 3 or any later version
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License as
  16. * published by the Free Software Foundation, either version 3 of the
  17. * License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. *
  27. */
  28. namespace OC\Core\Migrations;
  29. use Closure;
  30. use OCP\DB\Types;
  31. use OCP\DB\ISchemaWrapper;
  32. use OCP\Migration\IOutput;
  33. use OCP\Migration\SimpleMigrationStep;
  34. class Version17000Date20190514105811 extends SimpleMigrationStep {
  35. /**
  36. * @param IOutput $output
  37. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  38. * @param array $options
  39. * @return ISchemaWrapper
  40. */
  41. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  42. /** @var ISchemaWrapper $schema */
  43. $schema = $schemaClosure();
  44. if (!$schema->hasTable('filecache_extended')) {
  45. $table = $schema->createTable('filecache_extended');
  46. $table->addColumn('fileid', Types::BIGINT, [
  47. 'notnull' => true,
  48. 'length' => 4,
  49. 'unsigned' => true,
  50. ]);
  51. $table->addColumn('metadata_etag', Types::STRING, [
  52. 'notnull' => false,
  53. 'length' => 40,
  54. ]);
  55. $table->addColumn('creation_time', Types::BIGINT, [
  56. 'notnull' => true,
  57. 'length' => 20,
  58. 'default' => 0,
  59. ]);
  60. $table->addColumn('upload_time', Types::BIGINT, [
  61. 'notnull' => true,
  62. 'length' => 20,
  63. 'default' => 0,
  64. ]);
  65. $table->setPrimaryKey(['fileid'], 'fce_pk');
  66. // $table->addUniqueIndex(['fileid'], 'fce_fileid_idx');
  67. $table->addIndex(['creation_time'], 'fce_ctime_idx');
  68. $table->addIndex(['upload_time'], 'fce_utime_idx');
  69. }
  70. return $schema;
  71. }
  72. }