Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#102 Reset status for deposits completed before 2025-01-23 #103

Open
wants to merge 1 commit into
base: stable-3_3_0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}