diff options
author | René Gieling <github@dartcafe.de> | 2021-07-05 15:20:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-05 15:20:01 +0300 |
commit | 6708a60c26d04cf7f89d0137d2a12fb1bb45cebe (patch) | |
tree | a389792cfc4b08d220aba703e27c6d3964b5f033 /lib/Migration/Version030000Date20210704120000.php | |
parent | 1f3b494cd60d9972b05ed273e91efdc3754c74ec (diff) | |
parent | df66373fbed0a146bcecd277349d3525221c61c4 (diff) |
Merge pull request #1809 from nextcloud/version/3.0.0-rc.2v3.0.0-rc.2
Version/3.0.0 rc.2
Diffstat (limited to 'lib/Migration/Version030000Date20210704120000.php')
-rw-r--r-- | lib/Migration/Version030000Date20210704120000.php | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/lib/Migration/Version030000Date20210704120000.php b/lib/Migration/Version030000Date20210704120000.php new file mode 100644 index 00000000..f2a05ec3 --- /dev/null +++ b/lib/Migration/Version030000Date20210704120000.php @@ -0,0 +1,84 @@ +<?php +/** + * @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de> + * + * @author René Gieling <github@dartcafe.de> + * + * @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\Polls\Migration; + +use OCP\DB\ISchemaWrapper; +use OCP\IConfig; +use OCP\IDBConnection; +use OCP\Migration\SimpleMigrationStep; +use OCP\Migration\IOutput; + +// use Doctrine\DBAL\Types\Type; + +/** + * Installation class for the polls app. + * Initial db creation + * Changed class naming: Version[jjmmpp]Date[YYYYMMDDHHMMSS] + * Version: jj = major version, mm = minor, pp = patch + */ +class Version030000Date20210704120000 extends SimpleMigrationStep { + + /** @var IDBConnection */ + protected $connection; + + /** @var IConfig */ + protected $config; + + /** @var FixVotes */ + protected $fixVotes; + + public function __construct(IDBConnection $connection, IConfig $config, FixVotes $fixVotes) { + $this->connection = $connection; + $this->config = $config; + $this->fixVotes = $fixVotes; + } + + /** + * $schemaClosure The `\Closure` returns a `ISchemaWrapper` + */ + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + if ($schema->hasTable('polls_polls')) { + // Call initial migration from class TableSchema + // Drop old tables, which are migrated in prior versions + TableSchema::removeObsoleteTables($schema, $output); + + // Drop old columns, which are migrated in prior versions + TableSchema::removeObsoleteColumns($schema, $output); + } + + // Create tables, as defined in TableSchema or fix column definitions + TableSchema::CreateOrUpdateSchema($schema, $output); + // remove old migration entries from versions prior to polls 3.x + // including migration versions from test releases + // theoretically, only this migration should be existen. If not, no matter + TableSchema::removeObsoleteMigrations($this->connection, $output); + + $this->fixVotes->run($output); + + return $schema; + } +} |