From 0ca116f30bd4113c114ad8a46df0bb1972dd60bb Mon Sep 17 00:00:00 2001 From: huangjx Date: Tue, 14 Sep 2021 22:07:00 +0800 Subject: [PATCH] bumped the version number;updated database schema; --- appinfo/info.xml | 2 +- lib/Migration/Version00001date20210807.php | 2 +- lib/Migration/Version00002date20210912.php | 81 ++++++++++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 lib/Migration/Version00002date20210912.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 964e89e..efac726 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ Aria2 and youtube-dl web gui for nextcloud built-in torrent search;Start and stop Aria2 process, manage Aria2 from the web; Download videos from youtube, twitter and other sites; - 0.0.2 + 0.0.3 agpl jiaxinhuang NCDownloader diff --git a/lib/Migration/Version00001date20210807.php b/lib/Migration/Version00001date20210807.php index 31a9bae..684d5e7 100644 --- a/lib/Migration/Version00001date20210807.php +++ b/lib/Migration/Version00001date20210807.php @@ -79,7 +79,7 @@ class Version00001date20210807 extends SimpleMigrationStep 'notnull' => false, 'default' => null, ]); - $table->setPrimaryKey(['id','gid']); + $table->setPrimaryKey(['id']); } return $schema; } diff --git a/lib/Migration/Version00002date20210912.php b/lib/Migration/Version00002date20210912.php new file mode 100644 index 0000000..41e2fa0 --- /dev/null +++ b/lib/Migration/Version00002date20210912.php @@ -0,0 +1,81 @@ + + * + * @author Joas Schilling + * + * @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 . + * + */ +namespace OCA\NCDownloader\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\IDBConnection; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version00002date20210912 extends SimpleMigrationStep +{ + + /** @var IDBConnection */ + protected $connection; + + public function __construct(IDBConnection $connection) + { + $this->connection = $connection; + } + + /** + * @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(); + + $table = $schema->getTable('ncdownloader_info'); + if (!$table->hasColumn('speed')) { + $table->addColumn('speed', 'string', [ + 'notnull' => true, + 'length' => 255, + 'default' => 'unknown', + ]); + } + if (!$table->hasColumn('progress')) { + $table->addColumn('progress', 'string', [ + 'notnull' => true, + 'length' => 255, + 'default' => '0', + ]); + } + if (!$table->hasColumn('filesize')) { + $table->addColumn('filesize', 'string', [ + 'notnull' => false, + 'length' => 255, + 'default' => '', + ]); + } + $table->addUniqueIndex(['gid'], 'gid_index'); + return $schema; + } + +}