f7cloud_client/apps/updatenotification/lib/Migration/Version011901Date20240305120000.php
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

59 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 F7cloud GmbH and F7cloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\UpdateNotification\Migration;
use OCA\UpdateNotification\BackgroundJob\ResetToken;
use OCA\UpdateNotification\Notification\BackgroundJob;
use OCA\UpdateNotification\ResetTokenBackgroundJob;
use OCP\BackgroundJob\IJobList;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Drop this with F7cloud 30
*/
class Version011901Date20240305120000 extends SimpleMigrationStep {
public function __construct(
private IJobList $joblist,
) {
}
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void {
/**
* Remove and replace the reset-updater-token background job
* This class was renamed so it is now unknow but we still need to remove it
* @psalm-suppress UndefinedClass, InvalidArgument
*/
$hasOldResetToken = $this->joblist->has(ResetTokenBackgroundJob::class, null);
$hasNewResetToken = $this->joblist->has(ResetToken::class, null);
if ($hasOldResetToken) {
/**
* @psalm-suppress UndefinedClass, InvalidArgument
*/
$this->joblist->remove(ResetTokenBackgroundJob::class);
if (!$hasNewResetToken) {
$this->joblist->add(ResetToken::class);
}
}
/**
* Remove the "has updates" background job, the new one is automatically started from the info.xml
* @psalm-suppress UndefinedClass, InvalidArgument
*/
if ($this->joblist->has(BackgroundJob::class, null)) {
/**
* @psalm-suppress UndefinedClass, InvalidArgument
*/
$this->joblist->remove(BackgroundJob::class);
}
}
}