Institutional Subscriptions break upgrade to OJS 3.4.0.4 (from 3.3.0.16)

Describe the issue or problem
Hi - this is very similar to Another upgrade from 3.3 to 3.4 issue - fails with error about dois table. How to continue?

I upgrade an OJS installation from 3.3.0.16 to 3.4.0.4.

This one fails with

2024-01-12 11:16:39 [downgrade for "PKP\migration\upgrade\v3_4_0\I6895_CreateNewInstitutionsTables" unsupported: Downgrade not supported]
ERROR: Upgrade failed: DB: SQLSTATE[23502]: Not null violation: 7 ERROR:  column "institution_id" of relation "institutional_subscriptions" contains null values (SQL: alter table "institutional_subscriptions" add column "institution_id" bigint not null)

Steps I took leading up to the issue
For example:

  1. php tools/upgrade.php check
  2. php tools/upgrade.php upgrade
  3. See error

What application are you using?
For example, OJS 3.3.0-16

Additional information

This journal has around 200 institutional subscriptions.

From what I can see the tables institutions, institutions_settings and institutions_ip are empty.

Earlier in the migration there was the message:

2024-01-12 11:15:58 [Removing orphaned entries from "institutional_subscriptions" with an invalid value for the required column "subscription_id". The following IDs do not exist at the reference table "subscriptions":
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 58, 59, 60, 62, 63, 64, 66, 84, 85, 87, 88, 89, 90, 92, 95, 98, 100, 101, 102, 104, 105, 106, 109, 110, 114, 145, 267, 304]

So far I have the impression the institutions tables should not be empty. So far couldn’t find if there was code that would do that. Next week I’ll try to come up with a migration that fills them. though a bit worried that as I don’t want to accidentally lose or disable paid subscribers.

Hi @cager,

The error “Removing orphaned entries from…” (second that you mentioned) means that you had entries in your DB table institutional_subscriptions that have no valid subscription IDs – the IDs seem not to exist in the table subscriptions. Is this the case? Those entries are then removed during the upgrade.
Thus, maybe to double check how was that possible and that those are not the current institutional subscription that you need. I suppose that it is all right to delete them…

Regarding the actual error “Not null violation…” (the first that you mentioned): it seems we can not add a new NOT NULL column to an existing/pre-populated table. This we will need to fix. Please follow this issue for a fix for that: Adding a new not null column leads to an error if the table contains entries · Issue #9617 · pkp/pkp-lib · GitHub.
There is however one thing that I do not understand here: Why the error is happening in I6895_CreateNewInstitutionsTables – it actually should be in I6895_Institutions :thinking:
I will need to double check/test…
Is it then so that your institutional_subscriptions table does not have the new column institution_id after the upgrade?
I suppose that the institutions table could not be populated because that script I6895_Institutions failed on adding that new column, so it could not be executed further.

Is it possible for you to revert the backup and start the upgrade again once that issue is fixed?

Thanks,
Bozana

1 Like

Hi @bozana

no problem about returning - I experiment on a containerized clone. Rolling back is no problem.

about the orphaned, I will investigate, but suppose these are fine. This is a long running journal starting somewhere with ojs2 and originally shared the installation with other journals which moved to their own hosting.

Funny as you write - I just experimented with adding a default value to I6895_Institutions.php. So far it passes the Institutions migration. But fails at I7470_FixDeprecatedFileStage - but need to see what’s going on there first.

Thanks

Hi, just wanted to let you know. Using the the ojs version including the patch you provided, I was able to proceed with my upgrade.

Worked like a charm, thanks for acting so quickly!

1 Like