Upgrade from 2.4 to 3.0.2 and 3.1 failed

Hello, i’m trying to update OJS version from 2.4 to 3.0.2 but i’ve encountered the error below:

PHP Fatal error: Call to undefined method Installer::Installer() in /var/www/html/xxx/classes/install/Upgrade.inc.php on line 25

This error occurs in this following step:

  1. Command-line

If you have the CLI version of PHP installed (e.g., /usr/bin/php), you can
upgrade the database as follows:

- Edit config.inc.php and change "installed = On" to "installed = Off"
- Run the following command from the OJS directory (not including the $):
  $ php tools/upgrade.php upgrade
- Re-edit config.inc.php and change "installed = Off" back to
   "installed = On"
  1. Web

If you do not have the PHP CLI installed, you can also upgrade by running a
web-based script. To do so:

- Edit config.inc.php and change "installed = On" to "installed = Off"
- Open a web browser to your OJS site; you should be redirected to the
  installation and upgrade page
- Select the "Upgrade" link and follow the on-screen instructions
- Re-edit config.inc.php and change "installed = Off" back to
   "installed = On"

And trying to upgrade from web i get error 500 when loading url: http://url.com/index.php/index/install/installUpgrade

Hi @gustavov,

I don’t quite understand what you’re asking. Did you try following the directions given?

Thanks,
Amanda Stevens
Public Knowledge Project Team

Yes and i CAN’T upgrade de database successfully.

As i couldn’t successfully upgrade to 3.0.2 i’ve tried to upgrade to 3.1 but then i got the following error:

ERROR: type “serial” does not exist

So i’ve applied the patch postgresql-serials.diff, with the following errors:

Some parts failed:

patching file ./lib/pkp/lib/adodb/adodb-datadict.inc.php
patching file ./lib/pkp/lib/adodb/adodb-datadict.inc.php
Hunk #1 FAILED at 193.
Hunk #2 FAILED at 599.
2 out of 2 hunks FAILED – saving rejects to file ./lib/pkp/lib/adodb/adodb-datadict.inc.php.rej

After that i’m facing this error:

ERROR: relation “articles” does not exists

Hello again,

I did a git clone, dropped the DB and did the upgrade to version 3.1 from scratch.

I’ve applied the patch (postgresql-serials.diff) on files:

lib/pkp/lib/adodb/datadict/datadict-postgres.inc.php
lib/pkp/lib/adodb/adodb-datadict.inc.php

But still get this error:

PHP Warning: pg_query(): Query failed: ERROR: type “serial” does not exist in /var/www/html/xxx/lib/pkp/lib/adodb/drivers/adodb-postgres7.inc.php on line 230
-1: ERROR: type “serial” does not exist
ADOConnection._Execute(ALTER TABLE auth_sources ALTER COLUMN auth_id TYPE SERIAL, false)% line 1051, file: /var/www/html/xxx/lib/pkp/lib/adodb/adodb.inc.php
ADOConnection.Execute(ALTER TABLE auth_sources ALTER COLUMN auth_id TYPE SERIAL)% line 440, file: /var/www/html/xxx/lib/pkp/classes/install/Installer.inc.php
Installer.executeSQL(ALTER TABLE auth_sources ALTER COLUMN auth_id TYPE SERIAL)% line 435, file: /var/www/html/xxx/lib/pkp/classes/install/Installer.inc.php
Installer.executeSQL(Array[278])% line 375, file: /var/www/html/xxx/lib/pkp/classes/install/Installer.inc.php
Installer.executeAction(Array[3])% line 265, file: /var/www/xxx/revista/lib/pkp/classes/install/Installer.inc.php
ERROR: Upgrade failed: DB: ERROR: type “serial” does not exist

Well, it seems i’m running in circles…

After using the patched files from Patch postgres serial-errors for adodb to allow update (see #1793 for… · ubbdst/pkp-lib@b29444d · GitHub, i’m getting this error:

(postgres7): UPDATE submission_files SET genre_id = g.genre_id FROM genres g, submissions s, article_galleys_migration agm WHERE g.entry_key = ‘STYLE’ AND g.context_id = s.context_id AND s.submission_id = submission_files.submission_id AND sf.file_id = agm.style_file_id  


-1: ERROR: missing FROM-clause entry for table "sf" LINE 1: ...ubmission_id = submission_files.submission_id AND sf.file_id...

Hi @gustavov,

That error message has already been posted at Error while upgrading OJS from 2.4.8 to 3.1 + postgres only and a change is proposed there.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Hello.

Thanks for the help.

I’ve managed to upgrade it successfully after chaging some coding in the upgrade script.

Here is the 2 patchs that corrects all the bugs i’ve found in the upgrade process from 2.4.4 to 3.1.

Corrects 3.0.0.0_upgrade.xml file:

--- /root/ojs-3.1.0/dbscripts/xml/upgrade/3.0.0_update.xml	2017-10-24 01:04:36.000000000 -0200
+++ dbscripts/xml/upgrade/3.0.0_update.xml	2017-10-30 10:38:30.228171132 -0200
@@ -87,19 +87,19 @@
 		<!-- issue #2506: the genre_id for 'article' from genres.xml -->
	<query driver="mysql">UPDATE submission_files sf, genres g, submissions s SET sf.genre_id = g.genre_id WHERE g.entry_key = 'SUBMISSION' AND g.context_id = s.context_id AND     s.submission_id = sf.submission_id</query>
	<query driver="mysqli">UPDATE submission_files sf, genres g, submissions s SET sf.genre_id = g.genre_id WHERE g.entry_key = 'SUBMISSION' AND g.context_id = s.context_id AND     s.submission_id = sf.submission_id</query>
-		<query driver="postgres7">UPDATE submission_files SET genre_id = g.genre_id FROM genres g, submissions s WHERE g.entry_key = 'SUBMISSION' AND g.context_id = s.context_id AND     s.submission_id = submission_files.submission_id</query>
+		<query driver="postgres7">UPDATE submission_files sf SET genre_id = g.genre_id FROM genres g, submissions s WHERE g.entry_key = 'SUBMISSION' AND g.context_id = s.context_id AND     s.submission_id = sf.submission_id</query>
</sql>
<!-- issue #2758: the genre_id for HTML galley CSS files -->
<sql>
	<query driver="mysql">UPDATE submission_files sf, genres g, submissions s, article_galleys_migration agm SET sf.genre_id = g.genre_id WHERE g.entry_key = 'STYLE' AND g.context_id =     s.context_id AND s.submission_id = sf.submission_id AND sf.file_id = agm.style_file_id</query>
	<query driver="mysqli">UPDATE submission_files sf, genres g, submissions s, article_galleys_migration agm SET sf.genre_id = g.genre_id WHERE g.entry_key = 'STYLE' AND g.context_id =     s.context_id AND s.submission_id = sf.submission_id AND sf.file_id = agm.style_file_id</query>
-		<query driver="postgres7">UPDATE submission_files SET genre_id = g.genre_id FROM genres g, submissions s, article_galleys_migration agm WHERE g.entry_key = 'STYLE' AND g.context_id     = s.context_id AND s.submission_id = submission_files.submission_id AND sf.file_id = agm.style_file_id</query>
+		<query driver="postgres7">UPDATE submission_files sf SET genre_id = g.genre_id FROM genres g, submissions s, article_galleys_migration agm WHERE g.entry_key = 'STYLE' AND     g.context_id = s.context_id AND s.submission_id = sf.submission_id AND sf.file_id = agm.style_file_id</query>
</sql>
<!-- issue #2758: set assoc_type = 515 (ASSOC_TYPE_SUBMISSION_FILE) and the appropriate assoc_id for HTML galley CSS files -->
<sql>
	<query driver="mysql">UPDATE submission_files sf, article_galleys_migration agm SET sf.assoc_type = 515, sf.assoc_id = agm.file_id WHERE sf.file_id = agm.style_file_id</query>
	<query driver="mysqli">UPDATE submission_files sf, article_galleys_migration agm SET sf.assoc_type = 515, sf.assoc_id = agm.file_id WHERE sf.file_id = agm.style_file_id</query>
-		<query driver="postgres7">UPDATE submission_files SET assoc_type = 515, assoc_id = agm.file_id FROM article_galleys_migration agm WHERE sf.file_id = agm.style_file_id</query>
+		<query driver="postgres7">UPDATE submission_files sf SET assoc_type = 515, assoc_id = agm.file_id FROM article_galleys_migration agm WHERE sf.file_id = agm.style_file_id</query>
</sql>
<!-- Bug #7745: Change no_NO to nb_NO -->
<sql>

Corrects postgres ADODB drivers:

diff --git a/lib/pkp/lib/adodb/adodb-datadict.inc.php b/lib/pkp/lib/adodb/adodb-datadict.inc.php
index 4a44dc0..d2f317d 100644
--- a/lib/pkp/lib/adodb/adodb-datadict.inc.php
+++ b/lib/pkp/lib/adodb/adodb-datadict.inc.php
@@ -516,7 +516,9 @@ class ADODB_DataDict {
{
	$tabname = $this->TableName ($tabname);
	if ($flds) {
-			list($lines,$pkey,$idxs) = $this->_GenFields($flds);
+			// Avoid use of SERIAL for existing columns, 2014-04-14
+			// by AS
+			list($lines,$pkey,$idxs) = $this->_GenFields($flds, false, false);
		// genfields can return FALSE at times
		if ($lines == null) $lines = array();
		list(,$first) = each($lines);
@@ -595,7 +597,7 @@ class ADODB_DataDict {



-	function _GenFields($flds,$widespacing=false)
+	function _GenFields($flds,$widespacing=false,$allowSerial=true)
{
	if (is_string($flds)) {
		$padding = '     ';
@@ -684,7 +686,9 @@ class ADODB_DataDict {
							break;
			case 'UNSIGNED': $funsigned = true; break;
			case 'AUTOINCREMENT':
-				case 'AUTO':	$fautoinc = true; $fnotnull = true; break;
+				case 'AUTO':	// Serial type (psql) not allowed in ALTER TABLE statements (2014-04-14 AS)
+						if ($allowSerial) $fautoinc = true;
+						$fnotnull = true; break;
			case 'KEY':
             // a primary key col can be non unique in itself (if key spans many cols...)
			case 'PRIMARY':	$fprimary = $v; $fnotnull = true; /*$funiqueindex = true;*/ break;
@@ -1000,7 +1004,9 @@ class ADODB_DataDict {
	} */

	// already exists, alter table instead
-		list($lines,$pkey,$idxs) = $this->_GenFields($flds);
+		// (Avoid use of SERIAL when altering existing fields for psql,
+		// 2014-04-14 by AS)
+		list($lines,$pkey,$idxs) = $this->_GenFields($flds, false, false);
	// genfields can return FALSE at times
	if ($lines == null) $lines = array();
	$alter = 'ALTER TABLE ' . $this->TableName($tablename);
@@ -1068,4 +1074,4 @@ class ADODB_DataDict {
	$this->charSet = $charset_name;
}
 } // class
-?>
\ No newline at end of file
+?>
diff --git a/lib/pkp/lib/adodb/datadict/datadict-postgres.inc.php b/lib/pkp/lib/adodb/datadict/datadict-    postgres.inc.php
index af6cf3b..6edebb2 100644
--- a/lib/pkp/lib/adodb/datadict/datadict-postgres.inc.php
+++ b/lib/pkp/lib/adodb/datadict/datadict-postgres.inc.php
@@ -193,7 +193,9 @@ class ADODB2_postgres extends ADODB_DataDict {
   if ($has_alter_column) {
      $tabname = $this->TableName($tabname);
      $sql = array();
-	      list($lines,$pkey) = $this->_GenFields($flds);
+	      // Avoid use of SERIAL when altering an existing column
+	      // 2014-04-14 by AS
+	      list($lines,$pkey) = $this->_GenFields($flds, false, false);
	  $set_null = false;
      $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
      foreach($lines as $v) {
@@ -599,4 +601,4 @@ CREATE [ UNIQUE ] INDEX index_name ON table
	return $sql;
}
 }
-?>
\ No newline at end of file
+?>

Hi @gustavov,

The changes to 3.0.0_update.xml are already filed and committed here: Correct missing table alias for PostgreSQL upgrade · Issue #2989 · pkp/pkp-lib · GitHub

The second patch is to correct the issue described in this thread: Upgrade failure (Postgresql)

We’re not merging that change into the OJS distribution because we’re trying to avoid maintaining local patches of third-party code. There are some relevant issues that will solve this in another way: Test migration of ADODB to Composer dependency · Issue #2353 · pkp/pkp-lib · GitHub and https://github.com/pkp/pkp-lib/issues/2493.

Regards,
Alec Smecher
Public Knowledge Project Team