Skip to content

Commit

Permalink
#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 30, 2025
1 parent feb6491 commit 38e4db7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion classes/migration/install/PLNPluginSchemaMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function up() {
// Create a new scheduled_tasks entry for this plugin
Capsule::table('scheduled_tasks')->insertOrIgnore(['class_name' => 'plugins.generic.pln.classes.tasks.Depositor']);

foreach (['I35_FixMissingField', 'I28_FixDepositStatus'] as $class) {
foreach (['I35_FixMissingField', 'I28_FixDepositStatus', 'I102_ResetCompletedDeposits'] as $class) {
import("plugins.generic.pln.classes.migration.upgrade.{$class}");
(new $class())->up();
}
Expand Down
40 changes: 40 additions & 0 deletions classes/migration/upgrade/I102_ResetCompletedDeposits.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* @file classes/migration/upgrade/I102_ResetCompletedDeposits.inc.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.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Capsule\Manager as Capsule;
use PKP\install\DowngradeNotSupportedException;

class I102_ResetCompletedDeposits extends Migration {
/**
* Run the migrations.
* @return void
*/
public function up() {
// Reset status
Capsule::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]);
}

/**
* Rollback the migrations.
* @return void
*/
public function down() {
throw new DowngradeNotSupportedException();
}
}

0 comments on commit 38e4db7

Please sign in to comment.