Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[stable22] confirm migration feasibility" #1087

Merged
merged 1 commit into from
Jun 20, 2022
Merged
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
60 changes: 19 additions & 41 deletions lib/Service/MigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

namespace OCA\Circles\Service;

use OCA\Circles\Tools\Model\SimpleDataStore;
use OCA\Circles\Tools\Traits\TNCLogger;
use OCA\Circles\Tools\Traits\TStringTools;
use Exception;
use OC;
use OCA\Circles\AppInfo\Application;
Expand Down Expand Up @@ -61,9 +64,6 @@
use OCA\Circles\Model\Member;
use OCA\Circles\Model\Probes\CircleProbe;
use OCA\Circles\Model\ShareToken;
use OCA\Circles\Tools\Model\SimpleDataStore;
use OCA\Circles\Tools\Traits\TNCLogger;
use OCA\Circles\Tools\Traits\TStringTools;
use OCA\DAV\CardDAV\ContactsManager;
use OCP\Contacts\IManager;
use OCP\IDBConnection;
Expand Down Expand Up @@ -198,6 +198,8 @@ public function migration(bool $force = false): void {
);

$this->migrationTo22();
$this->migrationTo22_1();
// $this->migrationTo23();

$this->configService->setAppValue(ConfigService::MIGRATION_RUN, '0');
}
Expand All @@ -211,12 +213,6 @@ private function migrationTo22(): void {
return;
}

if (!$this->migrationTo22Feasibility()) {
$this->configService->setAppValue(ConfigService::MIGRATION_22, '1');

return;
}

$this->outputService->output('Migrating to 22');

$this->migrationTo22_Circles();
Expand All @@ -225,43 +221,11 @@ private function migrationTo22(): void {
$this->migrationTo22_Members_Memberships();

$this->migrationTo22_Tokens();
$this->migrationTo22_1_SubShares();

$this->configService->setAppValue(ConfigService::MIGRATION_22, '1');
}


/**
* run migration if:
* - old tables exist.
* - new tables are (almost) empty.
*
* @return bool
* @throws \OCP\DB\Exception
*/
public function migrationTo22Feasibility(): bool {
$qb = $this->dbConnection->getQueryBuilder();
$qb->select('*')->from('circle_circles');

try {
$cursor = $qb->executeQuery();
$cursor->closeCursor();
} catch (\OCP\DB\Exception $e) {
return false;
}

$qb = $this->dbConnection->getQueryBuilder();
$qb->select('*')->from('circles_circle');

$cursor = $qb->executeQuery();
if ($cursor->rowCount() > 1) {
return false;
}
$cursor->closeCursor();

return true;
}

/**
* @throws RequestBuilderException
*/
Expand Down Expand Up @@ -294,6 +258,20 @@ public function migrationTo22_Members_Memberships(): void {
}


/**
*
*/
private function migrationTo22_1(): void {
if ($this->configService->getAppValueBool(ConfigService::MIGRATION_22_1)) {
return;
}

$this->outputService->output('Migrating to 22.1.x');
$this->migrationTo22_1_SubShares();
$this->configService->setAppValue(ConfigService::MIGRATION_22_1, '1');
}


/**
*
*/
Expand Down