Skip to content

Commit

Permalink
Merge pull request #1085 from nextcloud/revert-1080-backport/1023/sta…
Browse files Browse the repository at this point in the history
…ble23

Revert "[stable23] confirm migration feasibility"
  • Loading branch information
blizzz committed Jun 17, 2022
2 parents 19ff5d9 + e39fd4f commit bd90f94
Showing 1 changed file with 19 additions and 41 deletions.
60 changes: 19 additions & 41 deletions lib/Service/MigrationService.php
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

0 comments on commit bd90f94

Please sign in to comment.