mirror of
https://github.com/nextcloud/server.git
synced 2026-10-31 18:15:57 +01:00
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace OCA\CloudFederationAPI\Migration;
|
|
|
|
use Closure;
|
|
use OCP\DB\ISchemaWrapper;
|
|
use OCP\IDBConnection;
|
|
use OCP\Migration\Attributes\DropTable;
|
|
use OCP\Migration\IOutput;
|
|
use OCP\Migration\SimpleMigrationStep;
|
|
use Override;
|
|
|
|
#[DropTable(table: 'ocm_token_map', description: 'Remove table used by previous implementation')]
|
|
class Version2000Date20260919141251 extends SimpleMigrationStep {
|
|
public function __construct(
|
|
private IDBConnection $connection,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* @param IOutput $output
|
|
* @param Closure(): ISchemaWrapper $schemaClosure
|
|
* @param array $options
|
|
*/
|
|
#[Override]
|
|
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
|
$query = $this->connection->getQueryBuilder();
|
|
$query->select('access_token_id')
|
|
->from('ocm_token_map');
|
|
|
|
$delete = $this->connection->getQueryBuilder();
|
|
$delete->delete('authtoken')
|
|
->where($delete->expr()->in('id', $query->createFunction($query->getSQL())));
|
|
$delete->executeStatement();
|
|
}
|
|
|
|
/**
|
|
* @param IOutput $output
|
|
* @param Closure(): ISchemaWrapper $schemaClosure
|
|
* @param array $options
|
|
* @return null|ISchemaWrapper
|
|
*/
|
|
#[Override]
|
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
|
/** @var ISchemaWrapper $schema */
|
|
$schema = $schemaClosure();
|
|
|
|
if (!$schema->hasTable('ocm_token_map')) {
|
|
return null;
|
|
}
|
|
|
|
$schema->dropTable('ocm_token_map');
|
|
return $schema;
|
|
}
|
|
}
|