nextcloud-swarm-plugin/lib/Migration/Version0001Date202204071430.php
2024-07-08 11:57:59 +02:00

89 lines
2.5 KiB
PHP
Executable File

<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022, MetaProvide Holding EKF
*
* @author Ron Trevor <ecoron@proton.me>
*
* @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 OCA\Files_External_Ethswarm\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use OCP\DB\Types;
class Version0001Date202204071430 extends SimpleMigrationStep {
public const _TABLENAME = "files_swarm";
/**
* @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(self::_TABLENAME)) {
$table = $schema->createTable(self::_TABLENAME);
$table->addColumn('id', Types::BIGINT, [
'autoincrement' => true,
'notnull' => true,
'length' => 20,
]);
$table->addColumn('storage', Types::BIGINT, [
'notnull' => true,
'length' => 20,
]);
$table->addColumn('name', Types::STRING, [
'notnull' => false,
'length' => 250,
]);
$table->addColumn('swarm_reference', Types::STRING, [
'notnull' => false,
'length' => 250,
]);
$table->addColumn('mimetype', Types::BIGINT, [
'notnull' => true,
'length' => 20,
'default' => 0,
]);
$table->addColumn('size', Types::BIGINT, [
'notnull' => true,
'length' => 8,
'default' => 0,
]);
$table->addColumn('storage_mtime', Types::BIGINT, [
'notnull' => true,
'length' => 20,
'default' => 0,
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['storage'], 'storage_index');
}
return $schema;
}
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
}
}