Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Column already exists: 1060 Duplicate column name

  • Kevin
  • Kevin's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 2 months ago - 7 years 2 months ago #148768 by Kevin
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: 7 years 2 months ago by Kevin.
The topic has been locked.
  • Kevin
  • Kevin's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 2 months ago #148772 by Kevin
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.
The topic has been locked.
  • Kevin
  • Kevin's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 2 months ago - 7 years 2 months ago #148773 by Kevin
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: 7 years 2 months ago by Kevin.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose