Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/appstore-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
filename: ${{ env.APP_NAME }}/appinfo/info.xml

- name: Set up php ${{ steps.php-versions.outputs.php-min }}
uses: shivammathur/setup-php@ccf2c627fe61b1b4d924adfcbd19d661a18133a0 # v2.35.2
uses: shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2.35.3
with:
php-version: ${{ steps.php-versions.outputs.php-min }}
coverage: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-php-cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1

- name: Set up php${{ steps.versions.outputs.php-min }}
uses: shivammathur/setup-php@ccf2c627fe61b1b4d924adfcbd19d661a18133a0 # v2.35.2
uses: shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2.35.3
with:
php-version: ${{ steps.versions.outputs.php-min }}
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
persist-credentials: false

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@ccf2c627fe61b1b4d924adfcbd19d661a18133a0 # v2.35.2
uses: shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2.35.3
with:
php-version: ${{ matrix.php-versions }}
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
path: apps/${{ env.APP_NAME }}

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@ccf2c627fe61b1b4d924adfcbd19d661a18133a0 # v2.35.2
uses: shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2.35.3
with:
php-version: ${{ matrix.php-versions }}
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
path: apps/${{ env.APP_NAME }}

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@ccf2c627fe61b1b4d924adfcbd19d661a18133a0 # v2.35.2
uses: shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2.35.3
with:
php-version: ${{ matrix.php-versions }}
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
path: apps/${{ env.APP_NAME }}

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@ccf2c627fe61b1b4d924adfcbd19d661a18133a0 # v2.35.2
uses: shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2.35.3
with:
php-version: ${{ matrix.php-versions }}
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
path: apps/${{ env.APP_NAME }}

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@ccf2c627fe61b1b4d924adfcbd19d661a18133a0 # v2.35.2
uses: shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2.35.3
with:
php-version: ${{ matrix.php-versions }}
# https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/psalm-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
persist-credentials: false

- name: Set up php${{ matrix.php-min }}
uses: shivammathur/setup-php@ccf2c627fe61b1b4d924adfcbd19d661a18133a0 # v2.35.2
uses: shivammathur/setup-php@20529878ed81ef8e78ddf08b480401e6101a850f # v2.35.3
with:
php-version: ${{ matrix.php-min }}
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
Expand Down
18 changes: 2 additions & 16 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<name>Polls</name>
<summary>A polls app, similar to Doodle/DuD-Poll with the possibility to restrict access.</summary>
<description>A polls app, similar to Doodle/DuD-Poll with the possibility to restrict access (members, certain groups/users, hidden and public).</description>
<version>8.3.0-beta.1</version>
<version>8.3.0-beta.3</version>
<licence>agpl</licence>
<author>Vinzenz Rosenkranz</author>
<author>René Gieling</author>
Expand All @@ -31,25 +31,11 @@
<job>OCA\Polls\Cron\JanitorCron</job>
<job>OCA\Polls\Cron\AutoReminderCron</job>
</background-jobs>
<repair-steps>
<pre-migration>
<step>OCA\Polls\Migration\RepairSteps\RemoveObsoleteMigrations</step>
</pre-migration>
<post-migration>
<step>OCA\Polls\Migration\RepairSteps\DropOrphanedTables</step>
<step>OCA\Polls\Migration\RepairSteps\DropOrphanedColumns</step>
<step>OCA\Polls\Migration\RepairSteps\DeleteInvalidRecords</step>
<step>OCA\Polls\Migration\RepairSteps\UpdateHashes</step>
<step>OCA\Polls\Migration\RepairSteps\CreateIndices</step>
</post-migration>
<install>
<step>OCA\Polls\Migration\RepairSteps\Install</step>
</install>
</repair-steps>
<commands>
<command>OCA\Polls\Command\Db\CleanMigrations</command>
<command>OCA\Polls\Command\Db\CreateIndices</command>
<command>OCA\Polls\Command\Db\Purge</command>
<command>OCA\Polls\Command\Db\FixDB</command>
<command>OCA\Polls\Command\Db\Rebuild</command>
<command>OCA\Polls\Command\Db\RemoveFKConstraints</command>
<command>OCA\Polls\Command\Db\RemoveOptionalIndices</command>
Expand Down
1 change: 1 addition & 0 deletions l10n/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ OC.L10N.register(
"minus" : "menos",
"plus" : "mas",
"Please wait…" : "Por favor, espere…",
"Possibly affected calendar events" : "Eventos de calendario posiblemente afectados",
"Add" : "Añadir",
"You are asked to propose more options." : "Se le pide que proponga más opciones.",
"The proposal period ends {timeRelative}." : "El período para las propuestas termina en {timeRelative}.",
Expand Down
1 change: 1 addition & 0 deletions l10n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@
"minus" : "menos",
"plus" : "mas",
"Please wait…" : "Por favor, espere…",
"Possibly affected calendar events" : "Eventos de calendario posiblemente afectados",
"Add" : "Añadir",
"You are asked to propose more options." : "Se le pide que proponga más opciones.",
"The proposal period ends {timeRelative}." : "El período para las propuestas termina en {timeRelative}.",
Expand Down
5 changes: 5 additions & 0 deletions lib/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Command extends \Symfony\Component\Console\Command\Command {
protected string $description = '';
protected array $operationHints = [];
protected bool $defaultContinueAnswer = false;
protected bool $skipQuestion = false;
protected mixed $helper;
protected InputInterface $input;
protected OutputInterface $output;
Expand Down Expand Up @@ -56,6 +57,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

protected function requestConfirmation(InputInterface $input, OutputInterface $output): int {
if ($this->skipQuestion) {
return 0;
}

if ($input->isInteractive()) {
/** @var QuestionHelper */
$this->helper = $this->getHelper('question');
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Db/CleanMigrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use Doctrine\DBAL\Schema\Schema;
use OCA\Polls\Command\Command;
use OCA\Polls\Db\TableManager;
use OCA\Polls\Db\V2\TableManager;
use OCP\IDBConnection;

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Db/CreateIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use Doctrine\DBAL\Schema\Schema;
use OCA\Polls\Command\Command;
use OCA\Polls\Db\IndexManager;
use OCA\Polls\Db\V2\IndexManager;
use OCP\IDBConnection;

/**
Expand Down
57 changes: 57 additions & 0 deletions lib/Command/Db/FixDB.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2021 Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Polls\Command\Db;

use Doctrine\DBAL\Schema\Schema;
use OCA\Polls\Command\Command;
use OCA\Polls\Db\V2\TableManager;
use OCP\IDBConnection;

/**
* @psalm-api
*/
class FixDB extends Command {
protected string $name = parent::NAME_PREFIX . 'db:fix';
protected string $description = 'Fix poll\'s table structure';
protected array $operationHints = [
'All polls tables will get checked and eventually updated against the current schema.',
'',
'Idices will not get updated, created or removed.',
'Note: NO data migration will be executed, so make sure you have a backup of your database.',
];

public function __construct(
private TableManager $tableManager,
private IDBConnection $connection,
private Schema $schema,
) {
parent::__construct();
}

protected function runCommands(): int {
$this->schema = $this->connection->createSchema();
$this->tableManager->setSchema($this->schema);

$this->createOrUpdateSchema();

$this->connection->migrateToSchema($this->schema);

return 0;
}

/**
* Iterate over tables and make sure, the are created or updated
* according to the schema
*/
private function createOrUpdateSchema(): void {
$this->printComment(' - Set db structure');
$messages = $this->tableManager->createTables();
$this->printInfo($messages, ' ');
}
}
2 changes: 1 addition & 1 deletion lib/Command/Db/Purge.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace OCA\Polls\Command\Db;

use OCA\Polls\Command\Command;
use OCA\Polls\Db\TableManager;
use OCA\Polls\Db\V2\TableManager;
use OCP\IDBConnection;

/**
Expand Down
51 changes: 30 additions & 21 deletions lib/Command/Db/Rebuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
namespace OCA\Polls\Command\Db;

use Doctrine\DBAL\Schema\Schema;
use OCA\Polls\Db\TableManager;
use OCA\Polls\Db\IndexManager;
use OCA\Polls\Db\V2\TableManager;
use OCA\Polls\Db\V2\IndexManager;
use OCA\Polls\Command\Command;
use OCP\IDBConnection;

Expand Down Expand Up @@ -52,32 +52,33 @@ protected function runCommands(): int {
$this->deleteGenericIndices();
$this->deleteUniqueIndices();
$this->deleteNamedIndices();

$this->printComment('Step 2. Remove all orphaned tables and columns');
$this->removeObsoleteTables();
$this->removeObsoleteColumns();

$this->connection->migrateToSchema($this->schema);

$this->printComment('Step 2. Tidy records before rebuilding the schema');
$this->fixNullish();
$this->cleanTables();

$this->printComment('Step 3. Create or update tables to current shema');
$this->createOrUpdateSchema();
$this->connection->migrateToSchema($this->schema);

$this->printComment('Step 4. Remove orphaned tables and columns');
$this->dropObsoleteTables();
$this->dropObsoleteColumns();
$this->connection->migrateToSchema($this->schema);

$this->printComment('Step 4. set hashes for votes and options');
$this->printComment('Step 5. Validate and fix records');
$this->migrateOptionsToHash();

$this->printComment('Step 5. Remove invalid records (orphaned and duplicates)');
$this->cleanTables();
$this->setLastInteraction();

$this->printComment('Step 6. Recreate unique indices and foreign key constraints');
$this->addForeignKeyConstraints();
$this->addUniqueIndices();
$this->connection->migrateToSchema($this->schema);

$this->printComment('Rebuild finished. The database structure is now up to date.');
$this->printComment('Execute \'occ db:add-missing-indices\' to add missing optional indices');

$this->connection->migrateToSchema($this->schema);

return 0;
}

Expand All @@ -90,6 +91,14 @@ private function addForeignKeyConstraints(): void {
$this->printInfo($messages, ' ');
}

private function fixNullish(): void {
$this->printComment(' - Fix nullish values');
$messages = $this->tableManager->fixNullishShares();
$this->printInfo($messages, ' ');

$messages = $this->tableManager->fixNullishPollGroupRelations();
$this->printInfo($messages, ' ');
}
/**
* Create index for $table
*/
Expand Down Expand Up @@ -118,7 +127,7 @@ private function migrateOptionsToHash(): void {
$this->printInfo($messages, ' ');
}

private function removeObsoleteColumns(): void {
private function dropObsoleteColumns(): void {
$this->printComment(' - Drop orphaned columns');
$messages = $this->tableManager->removeObsoleteColumns();
$this->printInfo($messages, ' ');
Expand All @@ -127,7 +136,7 @@ private function removeObsoleteColumns(): void {
/**
* Remove obsolete tables if they still exist
*/
private function removeObsoleteTables(): void {
private function dropObsoleteTables(): void {
$this->printComment(' - Drop orphaned tables');
$messages = $this->tableManager->removeObsoleteTables();
$this->printInfo($messages, ' ');
Expand All @@ -136,8 +145,8 @@ private function removeObsoleteTables(): void {
/**
* Initialize last poll interactions timestamps
*/
public function resetLastInteraction(): void {
$messages = $this->tableManager->resetLastInteraction();
public function setLastInteraction(): void {
$messages = $this->tableManager->setLastInteraction();
$this->printInfo($messages, ' ');
}

Expand All @@ -146,9 +155,9 @@ public function resetLastInteraction(): void {
*/
private function cleanTables(): void {
$this->printComment(' - Remove orphaned records');
$orphaned = $this->tableManager->removeOrphaned();
foreach ($orphaned as $table => $count) {
$this->printInfo(" Removed $count orphaned records from $table");
$messages = $this->tableManager->removeOrphaned();
foreach ($messages as $message) {
$this->printInfo(" $message");
}

$this->printComment(' - Remove duplicates');
Expand Down Expand Up @@ -187,7 +196,7 @@ private function deleteUniqueIndices(): void {
* remove all named indices
*/
private function deleteNamedIndices(): void {
$this->printComment(' - Remove common indices');
$this->printComment(' - Remove optional indices');
$messages = $this->indexManager->removeNamedIndices();
$this->printInfo($messages, ' - ');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Db/RemoveFKConstraints.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use Doctrine\DBAL\Schema\Schema;
use OCA\Polls\Command\Command;
use OCA\Polls\Db\IndexManager;
use OCA\Polls\Db\V2\IndexManager;
use OCP\IDBConnection;

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Db/RemoveOptionalIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use Doctrine\DBAL\Schema\Schema;
use OCA\Polls\Command\Command;
use OCA\Polls\Db\IndexManager;
use OCA\Polls\Db\V2\IndexManager;
use OCP\IDBConnection;

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/Db/RemoveUniqueIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use Doctrine\DBAL\Schema\Schema;
use OCA\Polls\Command\Command;
use OCA\Polls\Db\IndexManager;
use OCA\Polls\Db\V2\IndexManager;
use OCP\IDBConnection;

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/Command/Db/ResetWatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

use Doctrine\DBAL\Schema\Schema;
use OCA\Polls\Command\Command;
use OCA\Polls\Db\IndexManager;
use OCA\Polls\Db\TableManager;
use OCA\Polls\Db\V2\IndexManager;
use OCA\Polls\Db\V2\TableManager;
use OCA\Polls\Db\Watch;
use OCA\Polls\Migration\TableSchema;
use OCA\Polls\Migration\V2\TableSchema;
use OCP\IDBConnection;

/**
Expand Down
Loading