Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
In the process of developing a new site I thought everything was working ok then, when I tried to access the 'Admin' for Couch, I got this error:-

Could not successfully run query: Duplicate column name 'not_active'

I've looked in the database using phpMyAdmin but I can't find a duplicate column as suggested in the error message.

The only 'not_active' column I can see is in the table 'couch_fields'.

Help please?
Correct observation about table. Error appears as a result of Couch trying to upgrade itself by running file /couch/upgrade.php, particularly this part -
Code: Select all
    // upgrade to 2.2.beta
    if( version_compare("2.2.beta", $_ver, ">") ){
        $_sql = "ALTER TABLE `".K_TBL_FIELDS."` ADD `not_active` text;";
        $DB->_query( $_sql );
    }
Thank you. How do I solve the problem please?

By commenting out the section to upgrade to 2.2.beta; then, of course, everything works. However, is this an error in upgrade.php which should be permanently deleted?
@oldcelt, as @trendoman pointed out, Couch is trying (erroneously) to upgrade something that has already in place - this can happen when a previous upgrade is aborted midway.

Anyway, the fix is to comment out the offending statement like this -
open up /couch/upgrade.php in your editor, find the code block @trendoman mentioned and then add a '//' just before the $DB->_query( $_sql ); as shown below (which will comment the statement out) -
Code: Select all
// upgrade to 2.2.beta
if( version_compare("2.2.beta", $_ver, ">") ){
    $_sql = "ALTER TABLE `".K_TBL_FIELDS."` ADD `not_active` text;";
    // $DB->_query( $_sql );
}

In case after this you get another similar error, then there is on more code block just after the one mentioned above; please comment that one too and that should do it -
Code: Select all
// upgrade to 2.2.1
if( version_compare("2.2.1", $_ver, ">") ){
    $_sql = "ALTER TABLE `".K_TBL_FIELDS."` MODIFY `custom_params` mediumtext;";
    // $DB->_query( $_sql );
}

Hope this helps.
Thanks KK. You'll see from my edited message that I had already commented out the block identified by trendoman and that has worked fine.

I can't understand why it tried to run if the update had already been applied? I could, I suppose, go through update.php to try and find the reason. I have no idea how a previous attempt at update had been aborted part way through.
oldcelt wrote: By commenting out the section to upgrade to 2.2.beta; then, of course, everything works. However, is this an error in upgrade.php which should be permanently deleted?

Let's see how upgrade routine works.
Couch reads its current value set in couch/header.php -
Code: Select all
define( 'K_COUCH_VERSION', '2.2.1' ); // Changes with every release

Next, Couch compares version that value with the one that is requested from database (table `couch_settings`, column `k_couch_version`). If the version in file is greater than the version from database, the upgrade routine starts.

After upgrade is complete, Couch writes the new version to database. You can see that part in the end of couch/upgrade.php
Code: Select all
// Finally update version number


If the code never reached that point due to aborted upgrade, then the version in database was not updated.
Edit: It appears that database tables were already from a more recent version (already upgraded), but the version in database was less than the file's, hence the error.
Of course, thank you!

Problem is related to moving between live site and development environment. My fault entirely.

I'll be more careful in future :oops:
7 posts Page 1 of 1