DB Error: Unknown column 'ig.views' in 'field list'

I updated from 2.4.5 to 2.4.8-2 without any error. But at try update to 3.0.2 I always have the same problem:

DB Error: Unknown column 'ig.views' in 'field list'

Stack Trace:

File: /Users/glaucorobertomunsbergdossantos/Sites/revistas/classes/install/Upgrade.inc.php line 632
Function: DAO->update("INSERT INTO metrics (file_type, load_id, metric_type, assoc_type...", Array(8), False)

File: (unknown) line (unknown)
Function: Upgrade->migrateDefaultUsageStatistics(Object(Upgrade), Array(2))

File: /Users/glaucorobertomunsbergdossantos/Sites/revistas/lib/pkp/classes/install/Installer.inc.php line 415
Function: call_user_func(Array(2), Object(Upgrade), Array(2))

File: /Users/glaucorobertomunsbergdossantos/Sites/revistas/lib/pkp/classes/install/Installer.inc.php line 265
Function: Installer->executeAction(Array(3))

File: /Users/glaucorobertomunsbergdossantos/Sites/revistas/lib/pkp/classes/install/Installer.inc.php line 186
Function: Installer->executeInstaller()

File: /Users/glaucorobertomunsbergdossantos/Sites/revistas/lib/pkp/classes/install/form/UpgradeForm.inc.php line 40
Function: Installer->execute()

File: /Users/glaucorobertomunsbergdossantos/Sites/revistas/lib/pkp/pages/install/InstallHandler.inc.php line 110
Function: UpgradeForm->execute()

File: (unknown) line (unknown)
Function: InstallHandler->installUpgrade(Array(0), Object(Request))

File: /Users/glaucorobertomunsbergdossantos/Sites/revistas/lib/pkp/classes/core/PKPRouter.inc.php line 372
Function: call_user_func(Array(2), Array(0), Object(Request))

File: /Users/glaucorobertomunsbergdossantos/Sites/revistas/lib/pkp/classes/core/PKPPageRouter.inc.php line 239
Function: PKPRouter->_authorizeInitializeAndCallRequest(Array(2), Object(Request), Array(0), False)

File: /Users/glaucorobertomunsbergdossantos/Sites/revistas/lib/pkp/classes/core/Dispatcher.inc.php line 134
Function: PKPPageRouter->route(Object(Request))

File: /Users/glaucorobertomunsbergdossantos/Sites/revistas/lib/pkp/classes/core/PKPApplication.inc.php line 227
Function: Dispatcher->dispatch(Object(Request))

File: /Users/glaucorobertomunsbergdossantos/Sites/revistas/index.php line 68
Function: PKPApplication->execute()

Looking the issue opened by other user I can see that is not the same problem, but display similar message. I have the problem at metrics table and the other user in article_galleys. @asmecher can you help me?

Hi @Glauco_Roberto_Munsb

Hmmm… A little bit strange… Do you have the column “views” in your DB table “issue_galleys”?

Best,
Bozana

1 Like

Hi @bozana. This not exist in my table. Only the columns under

@bozana the same error occurred when doing update from 2.4.5 to 3.0.2

Hi @Glauco_Roberto_Munsb

Ah, yes, it is a bug in the upgrade script – those “views” DB columns were there only till the OJS 2.4.3…
Could you please apply this patch/changes: pkp/pkp-lib#2440 fix old default usage statistics migration by bozana · Pull Request #1350 · pkp/ojs · GitHub (EDIT: I changed the commit – this one is better)
and then try the clean upgrade again? – You can try the direct upgrade from 2.4.5 to 3.0.2…

Thanks a lot!
Best,
Bozana

Hi @bozana its patch solve my problem :smiley:
I upgrade from 2.4.5 to 3.0.2 without problems.
Thanks! :thumbsup:

Great! :-))) Thanks!

Hey,
we are using 2.4.8.3 and trying to upgrade to 3.1.1. The table issue_galleys does not have the column “views”. So I’m getting:

[code: Installer Installer::migrateDefaultUsageStatistics]

DB Error: Unknown column 'ig.views' in 'field list'

ojs2: DB Error: Unknown column 'ig.views' in 'field list'

I didnt understand the patch mentioned by @bozana . If the column “view” was removed in 2.4.3, why is it checking its existence now?

Hi @GustavoTonini

Hmmm…
The function migrateDefaultUsageStatistics should only be executed if the DB table article_galleys_stats_migration exists, s. ojs/upgrade.xml at ojs-3_1_1-0 · pkp/ojs · GitHub.
The DB table article_galleys_stats_migration is created in the script 2.4.0_preupdate_usageStatistics.xml, that should be executed only if the DB table issue_galleys has the column views. This is for those who are upgrading from OJS < 2.4.3.
Thus, if your 2.4.8.3 DB does not have the column views in the DB table issue_galleys, the script 2.4.0_preupdate_usageStatistics.xml is not executed during your upgrade. But, apparently you have the DB table article_galleys_stats_migration – it seems like that DB table stayed in your OJS 2.4.8.3 DB from an earlier upgrade? – so that the function migrateDefaultUsageStatistics is wrongly executed – it should not be executed, and the DB table article_galleys_stats_migration should not be there.
When did you do the upgrade from an OJS < 2.4.3?

Best,
Bozana

Thank you for answering, @bozana.

I dropped the table “article_galleys_stats_migration” and ran the upgrade again. Then, after some hours:

[data: dbscripts/xml/upgrade/3.0.0_update.xml]
ERROR: Upgrade failed: DB: Table ‘periodicosteste3.article_galleys_migration’ doesn’t exist

Hi @GustavoTonini

Hmmm… You started the upgread on a clean OJS 2.4.8 DB backup with the removed DB “article_galleys_stats_migration” i.e. not on a DB that you have already executed the upgrade on, correct? – just to double check…

The DB table “article_galleys_migration” is created in this script ojs/upgrade.xml at ojs-3_1_1-0 · pkp/ojs · GitHub, if column article_id exists in your DB table edit_decisions. Do you know if this is the case i.e. if this script was executed during your upgrade? – It seems like it wasn’t…
That table is then used in 3.0.0_update.xml (ojs/upgrade.xml at ojs-3_1_1-0 · pkp/ojs · GitHub) and finally removed in 3.0.0_postupdate.xml (ojs/upgrade.xml at ojs-3_1_1-0 · pkp/ojs · GitHub).

Best,
Bozana

Hello @bozana,
the column edit_decisions.article_id exists in the original 2.4.8.3 database. It does not exist anymore when the error is shown during the upgrade.

I have this mistake, too.

Hi all,

Hmmm… @GustavoTonini, but you do not have the table “article_galleys_migration” after trying the upgrade, correct?
If so, it seems like this SQL from ojs/upgrade.xml at ojs-3_1_1-0 · pkp/ojs · GitHub could not be executed successfully for you for some reason:
CREATE TABLE article_galleys_migration AS (SELECT galley_id, file_id, style_file_id FROM article_galleys)
After that script there should be the new DB table “article_galleys_migration”.
Could you maybe try to do it manually as the user configured in your config.inc.php? – Hmmm… :-\ At the moment I have no idea why this should not work well… Hmmm… :-\

Best,
Bozana

@bozana
The upgrade script passed this point after creating table “article_galleys_migration” manually.

Hmmm… strange that it was not crated by that upgrade script… but… however… I hope so is everything working OK for you now…

Best,
Bozana