Version17000Date20190514105811.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2019 Morris Jobke <hey@morrisjobke.de>
  5. *
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  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 OC\Core\Migrations;
  27. use Closure;
  28. use Doctrine\DBAL\Types\Type;
  29. use OCP\DB\ISchemaWrapper;
  30. use OCP\Migration\IOutput;
  31. use OCP\Migration\SimpleMigrationStep;
  32. class Version17000Date20190514105811 extends SimpleMigrationStep {
  33. /**
  34. * @param IOutput $output
  35. * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
  36. * @param array $options
  37. * @return ISchemaWrapper
  38. */
  39. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
  40. /** @var ISchemaWrapper $schema */
  41. $schema = $schemaClosure();
  42. if(!$schema->hasTable('filecache_extended')) {
  43. $table = $schema->createTable('filecache_extended');
  44. $table->addColumn('fileid', Type::BIGINT, [
  45. 'notnull' => true,
  46. 'length' => 4,
  47. 'unsigned' => true,
  48. ]);
  49. $table->addColumn('metadata_etag', Type::STRING, [
  50. 'notnull' => false,
  51. 'length' => 40,
  52. ]);
  53. $table->addColumn('creation_time', Type::BIGINT, [
  54. 'notnull' => true,
  55. 'length' => 20,
  56. 'default' => 0,
  57. ]);
  58. $table->addColumn('upload_time', Type::BIGINT, [
  59. 'notnull' => true,
  60. 'length' => 20,
  61. 'default' => 0,
  62. ]);
  63. $table->addUniqueIndex(['fileid'], 'fce_fileid_idx');
  64. $table->addIndex(['creation_time'], 'fce_ctime_idx');
  65. $table->addIndex(['upload_time'], 'fce_utime_idx');
  66. }
  67. return $schema;
  68. }
  69. }