diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2016-07-23 21:24:54 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2016-07-23 21:24:54 +0200 |
commit | 004fcbbcc7609ca83807f2e38967ef54f469bf72 (patch) | |
tree | 49eb99b4ea92b2045793fc567f719b31ec7f9042 /lib/Upgrade/Upgrade.php | |
parent | 60abc0ed4438c9b6fda245b0dc33cb483bc2aeaf (diff) |
Move to new directory structure
Diffstat (limited to 'lib/Upgrade/Upgrade.php')
-rw-r--r-- | lib/Upgrade/Upgrade.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/lib/Upgrade/Upgrade.php b/lib/Upgrade/Upgrade.php new file mode 100644 index 000000000..2ddcddb2c --- /dev/null +++ b/lib/Upgrade/Upgrade.php @@ -0,0 +1,71 @@ +<?php +/** + * ownCloud - News + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @copyright Bernhard Posselt 2015 + */ + +namespace OCA\News\Upgrade; + +use OCP\IConfig; +use OCA\News\Service\ItemService; +use OCP\IDBConnection; + +class Upgrade { + + /** @var IConfig */ + private $config; + + /** @var ItemService */ + private $itemService; + + private $appName; + /** + * @var IDBConnection + */ + private $db; + + /** + * Upgrade constructor. + * @param IConfig $config + * @param $appName + */ + public function __construct(IConfig $config, ItemService $itemService, + IDBConnection $db, $appName) { + $this->config = $config; + $this->appName = $appName; + $this->itemService = $itemService; + $this->db = $db; + } + + public function upgrade() { + $previousVersion = $this->config->getAppValue( + $this->appName, 'installed_version' + ); + + if (version_compare($previousVersion, '8.9.0', '<=')) { + $this->itemService->generateSearchIndices(); + } + } + + public function preUpgrade() { + $previousVersion = $this->config->getAppValue( + $this->appName, 'installed_version' + ); + + $dbType = $this->config->getSystemValue('dbtype'); + if (version_compare($previousVersion, '8.2.2', '<') && + $dbType !== 'sqlite3' + ) { + $sql = 'ALTER TABLE `*PREFIX*news_feeds` DROP COLUMN + `last_modified`'; + $query = $this->db->prepare($sql); + $query->execute(); + } + } + +} |