diff options
author | René Gieling <github@dartcafe.de> | 2021-03-07 21:34:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-07 21:34:07 +0300 |
commit | b07a825a513cecf05c8557a303fa3e8715010cbb (patch) | |
tree | 90cb83719089da7e806c49e3981503a97971d8f7 | |
parent | 612c6c470e10944d9800959678dd22335ca5f004 (diff) |
change migration (#1469)v1.8.0
change migration
-rw-r--r-- | CHANGELOG.md | 9 | ||||
-rw-r--r-- | appinfo/info.xml | 6 | ||||
-rw-r--r-- | lib/Migration/Version0108Date20210207134703.php | 67 | ||||
-rw-r--r-- | lib/Migration/Version0108Date20210307130001.php | 114 | ||||
-rw-r--r-- | lib/Migration/Version0108Date20210307130003.php (renamed from lib/Migration/Version0108Date20210127135802.php) | 32 | ||||
-rw-r--r-- | lib/Migration/Version0108Date20210307130009.php (renamed from lib/Migration/Version0108Date20210117010101.php) | 53 |
6 files changed, 194 insertions, 87 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 989033e3..2981cc67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. -## [2.0.0] - tbd -### supported NC version 21 -Same as 1.8.0 - -## [1.8.0] - tbd -### supported NC versions 19 - 20 +## [1.8.0 - beta1] - 2021-03-07 - [ux] #1164 - Wording: use list and table layout instead of desktop and mobile (#1443) - [ux] #1430 - Move poll informations to icon bar (info icon) (#1443) - - [ux] #1418 - Allow changing emailaddress in public polls (#1431) + - [ux] #1418 - Allow changing emailaddress in public polls (#1431) - [ux] #1401 - Change registation dialog layout (#1429) - [ux] #1400 - Optimizations for registration dialog on mobiles (#1429) - [enhancement] #325 - added markdown support for poll description (#1443) diff --git a/appinfo/info.xml b/appinfo/info.xml index 2511410a..c65259f3 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -23,19 +23,15 @@ <screenshot>https://raw.githubusercontent.com/nextcloud/polls/master/screenshots/vote.png</screenshot> <screenshot>https://raw.githubusercontent.com/nextcloud/polls/master/screenshots/edit-poll.png</screenshot> <dependencies> - <nextcloud min-version="19" max-version="20" /> + <nextcloud min-version="19" max-version="21" /> </dependencies> <background-jobs> <job>OCA\Polls\Cron\NotificationCron</job> </background-jobs> <repair-steps> <pre-migration> - <step>OCA\Polls\Migration\RemoveIndices</step> <step>OCA\Polls\Migration\DeleteDuplicates</step> </pre-migration> - <post-migration> - <step>OCA\Polls\Migration\CreateIndices</step> - </post-migration> </repair-steps> <navigations> <navigation> diff --git a/lib/Migration/Version0108Date20210207134703.php b/lib/Migration/Version0108Date20210207134703.php deleted file mode 100644 index 5d47bf25..00000000 --- a/lib/Migration/Version0108Date20210207134703.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2017 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; - -class Version0108Date20210207134703 extends SimpleMigrationStep { - - /** @var IDBConnection */ - protected $connection; - - /** @var IConfig */ - protected $config; - - public function __construct(IDBConnection $connection, IConfig $config) { - $this->connection = $connection; - $this->config = $config; - } - - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - if ($schema->hasTable('polls_polls')) { - $table = $schema->getTable('polls_polls'); - if (!$table->hasColumn('allow_comment')) { - $table->addColumn('allow_comment', 'integer', [ - 'length' => 11, - 'notnull' => true, - 'default' => 1 - ]); - } - if (!$table->hasColumn('hide_booked_up')) { - $table->addColumn('hide_booked_up', 'integer', [ - 'length' => 11, - 'notnull' => true, - 'default' => 1 - ]); - } - } - return $schema; - } -} diff --git a/lib/Migration/Version0108Date20210307130001.php b/lib/Migration/Version0108Date20210307130001.php new file mode 100644 index 00000000..e029e450 --- /dev/null +++ b/lib/Migration/Version0108Date20210307130001.php @@ -0,0 +1,114 @@ +<?php +/** + * @copyright Copyright (c) 2017 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; + +class Version0108Date20210307130001 extends SimpleMigrationStep { + + /** @var IDBConnection */ + protected $connection; + + /** @var IConfig */ + protected $config; + + public function __construct(IDBConnection $connection, IConfig $config) { + $this->connection = $connection; + $this->config = $config; + } + + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + if ($schema->hasTable('polls_options')) { + $table = $schema->getTable('polls_options'); + foreach ($table->getIndexes() as $index) { + if (strpos($index->getName(), 'UNIQ_') === 0) { + $table->dropIndex($index->getName()); + } + } + } + + if ($schema->hasTable('polls_log')) { + $table = $schema->getTable('polls_log'); + foreach ($table->getIndexes() as $index) { + if (strpos($index->getName(), 'UNIQ_') === 0) { + $table->dropIndex($index->getName()); + } + } + } + + if ($schema->hasTable('polls_notif')) { + $table = $schema->getTable('polls_notif'); + foreach ($table->getIndexes() as $index) { + if (strpos($index->getName(), 'UNIQ_') === 0) { + $table->dropIndex($index->getName()); + } + } + } + + if ($schema->hasTable('polls_share')) { + $table = $schema->getTable('polls_share'); + foreach ($table->getIndexes() as $index) { + if (strpos($index->getName(), 'UNIQ_') === 0) { + $table->dropIndex($index->getName()); + } + } + } + + if ($schema->hasTable('polls_votes')) { + $table = $schema->getTable('polls_votes'); + foreach ($table->getIndexes() as $index) { + if (strpos($index->getName(), 'UNIQ_') === 0) { + $table->dropIndex($index->getName()); + } + } + } + + if ($schema->hasTable('polls_preferences')) { + $table = $schema->getTable('polls_preferences'); + foreach ($table->getIndexes() as $index) { + if (strpos($index->getName(), 'UNIQ_') === 0) { + $table->dropIndex($index->getName()); + } + } + } + + if ($schema->hasTable('polls_watch')) { + $table = $schema->getTable('polls_watch'); + foreach ($table->getIndexes() as $index) { + if (strpos($index->getName(), 'UNIQ_') === 0) { + $table->dropIndex($index->getName()); + } + } + } + + return $schema; + } +} diff --git a/lib/Migration/Version0108Date20210127135802.php b/lib/Migration/Version0108Date20210307130003.php index 75c23fbd..c629c529 100644 --- a/lib/Migration/Version0108Date20210127135802.php +++ b/lib/Migration/Version0108Date20210307130003.php @@ -29,7 +29,7 @@ use OCP\IDBConnection; use OCP\Migration\SimpleMigrationStep; use OCP\Migration\IOutput; -class Version0108Date20210127135802 extends SimpleMigrationStep { +class Version0108Date20210307130003 extends SimpleMigrationStep { /** @var IDBConnection */ protected $connection; @@ -45,6 +45,36 @@ class Version0108Date20210127135802 extends SimpleMigrationStep { public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); + if ($schema->hasTable('polls_polls')) { + $table = $schema->getTable('polls_polls'); + if (!$table->hasColumn('allow_comment')) { + $table->addColumn('allow_comment', 'integer', [ + 'length' => 11, + 'notnull' => true, + 'default' => 1 + ]); + } + if (!$table->hasColumn('hide_booked_up')) { + $table->addColumn('hide_booked_up', 'integer', [ + 'length' => 11, + 'notnull' => true, + 'default' => 1 + ]); + } + } + + if ($schema->hasTable('polls_options')) { + $table = $schema->getTable('polls_options'); + + if (!$table->hasColumn('duration')) { + $table->addColumn('duration', 'integer', [ + 'length' => 11, + 'notnull' => true, + 'default' => 0 + ]); + } + } + if (!$schema->hasTable('polls_watch')) { $table = $schema->createTable('polls_watch'); $table->addColumn('id', 'integer', [ diff --git a/lib/Migration/Version0108Date20210117010101.php b/lib/Migration/Version0108Date20210307130009.php index 2d91fbac..8f7bf109 100644 --- a/lib/Migration/Version0108Date20210117010101.php +++ b/lib/Migration/Version0108Date20210307130009.php @@ -29,7 +29,7 @@ use OCP\IDBConnection; use OCP\Migration\SimpleMigrationStep; use OCP\Migration\IOutput; -class Version0108Date20210117010101 extends SimpleMigrationStep { +class Version0108Date20210307130009 extends SimpleMigrationStep { /** @var IDBConnection */ protected $connection; @@ -45,17 +45,56 @@ class Version0108Date20210117010101 extends SimpleMigrationStep { public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); + if ($schema->hasTable('polls_options')) { $table = $schema->getTable('polls_options'); + if (!$table->hasIndex('UNIQ_options')) { + $table->addUniqueIndex(['poll_id', 'poll_option_text', 'timestamp'], 'UNIQ_options'); + } + } + + if ($schema->hasTable('polls_log')) { + $table = $schema->getTable('polls_log'); + if (!$table->hasIndex('UNIQ_unprocessed')) { + $table->addUniqueIndex(['processed', 'poll_id', 'user_id', 'message_id'], 'UNIQ_unprocessed'); + } + } - if (!$table->hasColumn('duration')) { - $table->addColumn('duration', 'integer', [ - 'length' => 11, - 'notnull' => true, - 'default' => 0 - ]); + if ($schema->hasTable('polls_notif')) { + $table = $schema->getTable('polls_notif'); + if (!$table->hasIndex('UNIQ_subscription')) { + $table->addUniqueIndex(['poll_id', 'user_id'], 'UNIQ_subscription'); } } + + if ($schema->hasTable('polls_share')) { + $table = $schema->getTable('polls_share'); + if (!$table->hasIndex('UNIQ_shares')) { + $table->addUniqueIndex(['poll_id', 'user_id'], 'UNIQ_shares'); + } + } + + if ($schema->hasTable('polls_votes')) { + $table = $schema->getTable('polls_votes'); + if (!$table->hasIndex('UNIQ_votes')) { + $table->addUniqueIndex(['poll_id', 'user_id', 'vote_option_text'], 'UNIQ_votes'); + } + } + + if ($schema->hasTable('polls_preferences')) { + $table = $schema->getTable('polls_preferences'); + if (!$table->hasIndex('UNIQ_preferences')) { + $table->addUniqueIndex(['user_id'], 'UNIQ_preferences'); + } + } + + if ($schema->hasTable('polls_watch')) { + $table = $schema->getTable('polls_watch'); + if (!$table->hasIndex('UNIQ_watch')) { + $table->addUniqueIndex(['poll_id', 'table'], 'UNIQ_watch'); + } + } + return $schema; } } |