Column already exists: 1060 Duplicate column name

More
1 year 4 months ago - 1 year 4 months ago #148768 by Kevin
Kevin created the topic: Column already exists: 1060 Duplicate column name
I completed a manual upgrade from 2.56 to 2.62.2.

I saw these lines on the admin page:
Current database version: 260
Target database version: 261

I clicked on "Click her to continue" and I got this error:

An non-recoverable error happened during the update. Error details:
CDbCommand failed to execute the SQL statement: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'hash'

I looked around and discovered that the page is created from these files but I don't know how to correct the error.
locale/_template/limesurvey.pot
application/views/admin/databaseupdate/verify.php

Can someone please offer advice?
Thanks
Last Edit: 1 year 4 months ago by Kevin.

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago #148772 by Kevin
Kevin replied the topic: Column already exists: 1060 Duplicate column name
Debugging mode shows:
system.db.CDbCommand.execute(ALTER TABLE `survey_notifications` ADD `hash` varchar(64) )

I think it should be attempting to add an additional row that states, "The database has been updated from version 260 to version 261" instead of adding a column when it currently exists.

Please Log in or Create an account to join the conversation.

More
1 year 4 months ago - 1 year 4 months ago #148773 by Kevin
Kevin replied the topic: Column already exists: 1060 Duplicate column name
It's fixed. I must have tried the install it twice because the survey_notifications table had the "hash" column with the same date 2017-02-15 18:21:11 twice.

I changed these values from 0 in config.php
'debug'=>2,
'debugsql'=>1,

I was previously using database 260 and "application/helpers/update/updatedb_helper.php" has the following code:
if ($iOldDBVersion < 261) {
$oTransaction = $oDB->beginTransaction();
addColumn('{{notifications}}', 'hash', 'string(64)');
$oDB->createCommand()->createIndex('notif_hash_index', '{{notifications}}', 'hash', false);
$oDB->createCommand()->update('{{settings_global}}',array('stg_value'=>261),"stg_name='DBVersion'");
$oTransaction->commit();
}

I removed the rows in the the table "survey_notifications" that had the date 2017-02-15 18:21:11. Then I removed the "hash" column with the following command:

ALTER TABLE survey_notifications DROP hash;

Then I went to the url below and it worked.
<domain>/index.php/admin/authentication/sa/login

Continuing to refresh the web page that displayed, "Current database version: 260" and "Target database version: 261"
produced a syntax error after deleting the "'hash" column but re-added the column. I think this was the url: <domain>/index.php/admin/databaseupdate/sa/db

Commenting "addColumn('{{notifications}}', 'hash', 'string(64)');" in "application/helpers/update/updatedb_helper.php" might have also worked but I was trying to refresh the wrong url.

There might be a bug because the "hash" column was created before I got the software functional. Then I could not attempt a reinstall without removing the column from the database.
Last Edit: 1 year 4 months ago by Kevin.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!