Skip to content

Commit

Permalink
pkp#102 Reset status for deposits completed before 2025-01-23
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jan 31, 2025
1 parent a77c6b9 commit 290c25e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion classes/migration/install/SchemaMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace APP\plugins\generic\pln\classes\migration\install;

use APP\plugins\generic\pln\classes\migration\upgrade\I102_ResetCompletedDeposits;
use APP\plugins\generic\pln\classes\migration\upgrade\I28_FixDepositStatus;
use APP\plugins\generic\pln\classes\migration\upgrade\I35_FixMissingField;
use APP\plugins\generic\pln\classes\migration\upgrade\I57_UpdateSettings;
Expand Down Expand Up @@ -60,7 +61,7 @@ public function up(): void
}

/** @var class-string<Migration> $class */
foreach ([I35_FixMissingField::class, I28_FixDepositStatus::class, I57_UpdateSettings::class] as $class) {
foreach ([I35_FixMissingField::class, I28_FixDepositStatus::class, I57_UpdateSettings::class, I102_ResetCompletedDeposits::class] as $class) {
$migration = new $class();
$migration->up();
}
Expand Down
37 changes: 37 additions & 0 deletions classes/migration/upgrade/I102_ResetCompletedDeposits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/**
* @file classes/migration/upgrade/I102_ResetCompletedDeposits.php
*
* Copyright (c) 2025 Simon Fraser University
* Copyright (c) 2025 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file LICENSE.
*
* @class I102_ResetCompletedDeposits
* @brief Due to an issue in the Preservation Network server, deposits completed before 2025-01-23 should have their status refreshed.
*/

namespace APP\plugins\generic\pln\classes\migration\upgrade;

use DateTimeImmutable;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use PKP\install\DowngradeNotSupportedException;

class I102_ResetCompletedDeposits extends Migration
{
public function up(): void
{
// Reset status
DB::table('pln_deposits')
// PLN_PLUGIN_DEPOSIT_STATUS_LOCKSS_AGREEMENT (128) is set
->whereRaw('(status & 128) <> 0')
// The preserved date is set by the plugin, and not taken from the server, so this is enough to make the query safe to be re-executed
->whereDate('date_preserved', '<', new DateTimeImmutable('2025-01-23'))
->update(['status' => null]);
}

public function down() {
throw new DowngradeNotSupportedException();
}
}

0 comments on commit 290c25e

Please sign in to comment.