diff options
author | Joas Schilling <coding@schilljs.com> | 2018-09-14 12:34:24 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 20:56:15 +0100 |
commit | 69b530a44230028c278bda94984b7aaacd22a8a1 (patch) | |
tree | e88ef681df42cb2c5eda3cc08924eb6c2e0fbcbf /core | |
parent | 49b104f3df08b453258eb1483173dc0b8c5e022b (diff) | |
download | nextcloud-server-69b530a44230028c278bda94984b7aaacd22a8a1.tar.gz nextcloud-server-69b530a44230028c278bda94984b7aaacd22a8a1.zip |
Basic implementation of resource and collection handling
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/Migrations/Version15000Date20180917092725.php | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/core/Migrations/Version15000Date20180917092725.php b/core/Migrations/Version15000Date20180917092725.php new file mode 100644 index 00000000000..9dbc5efceda --- /dev/null +++ b/core/Migrations/Version15000Date20180917092725.php @@ -0,0 +1,76 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\Core\Migrations; + +use Closure; +use Doctrine\DBAL\Types\Type; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\SimpleMigrationStep; +use OCP\Migration\IOutput; + +class Version15000Date20180917092725 extends SimpleMigrationStep { + + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + if (!$schema->hasTable('collres_collections')) { + $table = $schema->createTable('collres_collections'); + + $table->addColumn('id', Type::BIGINT, [ + 'autoincrement' => true, + 'notnull' => true, + ]); + + $table->setPrimaryKey(['id']); + } + + if (!$schema->hasTable('collres_resources')) { + $table = $schema->createTable('collres_resources'); + + $table->addColumn('collection_id', Type::BIGINT, [ + 'notnull' => true, + ]); + $table->addColumn('resource_type', Type::STRING, [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('resource_id', Type::STRING, [ + 'notnull' => true, + 'length' => 64, + ]); + + $table->addUniqueIndex(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res'); + } + + return $schema; + } + +} |