SQLSTATE[42S22]: Column not found

Describe the issue or problem
I am unable to proceed with the upgrade from 3.3.0.14 to 3.4.0.1 due to the following error:

A database error has occurred: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'at.assoc_id' in 'on clause' (SQL: select distinct `at`.`type_id` from `announcement_types` as `at` left join `journals` as `c` on `at`.`assoc_id` = `c`.`journal_id` where `c`.`journal_id` is null or `at`.`assoc_type` <> 256)

Additional information

Hi @D_S,

This sounds quite similar to what was posted here: Error upgrade OJS to 3.4 - #4 by marc

You might want to try what is suggested there.

-Roger
PKP Team

I have already tried that solution. In my case, those tables exist before upgrade but are deleted during the upgradation process.

I have the same error as @D_S . I am upgrading from 3.3.0-8 to 3.4.0-1 on the latest version of XAMPP on Windows and get:

[A pre-flight check failed. The software was successfully upgraded to 3.3.9.9 but could not be upgraded further (to 3.4.0.1). Check and correct the error, then try again.]
ERROR: Upgrade failed: DB: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘at.assoc_type’ in ‘where clause’ (SQL: select distinct at.type_id from announcement_types as at left join journals as c on at.assoc_id = c.journal_id where c.journal_id is null or at.assoc_type <> 256)

I looked at Error upgrade OJS to 3.4 - #4 by marc, but it talks about changing the email section in the config and changing the database type from mysqli to mysql. Changing mysqli to mysql didn’t help, the error is the same. Upgrade check shows the updated db version and no errors:

c:\xampp\htdocs\journal>php tools\upgrade.php check
Code version: 3.4.0.1
Database version: 3.3.9.9
Latest version: 3.4.0.1
Database version is older than code version
Run “tools\upgrade.php upgrade” to update

What else could I try to be able to upgrade?

I haven’t solved it yet. I gave up at some point. We are still running the old version in which the email feature is buggy.

Hi all,

The error message…

SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘at.assoc_type’ in ‘where clause’ (SQL: select distinct at.type_id from announcement_types as at left join journals as c on at.assoc_id = c.journal_id where c.journal_id is null or at.assoc_type <> 256)

…indicates that you are attempting to run an upgrade on a database where the announcement_types table does not have a column named assoc_type.

A valid 3.3.0-x database should always have an assoc_type column on the announcement_types table, so if you encounter this message, your database is not what the upgrade tool expects.

The most likely cause is that you attempted an upgrade, got partway through, then experienced a failure. If that happens, you’ll need to restore your database from backup before trying again.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi all,

I reach this error only after some other query fails first.

Upgrading from 3.3.0-15 to 3.4.0-0 getting this error first:

  • A database error has occurred: SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘dois’ already exists (SQL: create table dois (doi_id bigint not null auto_increment primary key, context_id bigint not null, doi varchar(255) not null, status smallint not null default ‘1’) default character set utf8 collate ‘utf8_general_ci’)

I have dois table with data in my database, and announcement_types table have assoc_type.
There was another complain about ‘failed_jobs table already exist’ that table is empty in my database so I deleted it just to see if the upgrade will proceed, after it hit the error dois table already exists.

Any idea why existing tables are not handled by the upgrade?

Hi @farhad93,

When restoring a database from backup, make sure to drop and recreate it first. Otherwise you’ll be mixing old and new tables together, leading to errors like this.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher ,

Thanks for your reply, can you elaborate on ‘drop and recreate first’? The database should be dropped and recreated in the database management system and then proceed with the upgrade?

BR,
Farhad

Hi @farhad93,

This is more of a database administration question than an OJS question – but to fully restore a database to its state when the backup was taken, you need to run three steps:

  1. Drop (delete) the database
  2. Recreate the empty database
  3. Load the database dump into the database

You’re probably skipping steps 1 and 2. If you’re using CPanel, see https://docs.cpanel.net/cpanel/databases/mysql-databases/#create-a-database for details. (Be sure you’ve got a good backup first before working with these tools!)

If you do this right, after you’ve restored the database from 3.3.0-x you should see that the dois table will no longer exist (until you run the upgrade script, which creates it).

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher

Thanks for the info,
Just FYI I followed this tutorial for the upgrade.
https://openjournaltheme.com/docs/upgrade/how-to-upgrade-ojs-3

BR,
Farhad

This topic was automatically closed after 11 days. New replies are no longer allowed.