Upgrade from 2.4 to 3.0.2 and 3.1 failed

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
+?>