Hi,

I've just migrated my new website to D7.

When I run update.php, I've got this error :

captcha module
Update #6203

* Failed: DatabaseSchemaObjectDoesNotExistException: Cannot change the definition of field .captcha_points: field doesn't exist. in DatabaseSchema_mysql->changeField() (line 450 of /var/www/www.mydomain.com/includes/database/mysql/schema.inc).

Thanks for your reply

Comments

dedisoft’s picture

If I uninstall the module, and then reinstall it, all is ok.

I've never installed the version 7.x-1.0-alpha1 (I've seen http://drupal.org/node/1011154 before reporting the issue).

maggros’s picture

Hi -
I just applied this update and now we are getting the following error:

user warning: Unknown column 'token' in 'field list' query: UPDATE captcha_sessions SET token='1b06b191b75c538c0ec44b10977ab34c' WHERE csid=18292 in /home/jill/web/sites/all/modules/captcha/captcha.module on line 213.

What didn't I do?
TIA

maggros

soxofaan’s picture

@maggros: did you run the update.php (example.com/update.php) script?

soxofaan’s picture

@dedisoft (the original problem of this thread)

Ouch, this is nasty problem: the update code is

function captcha_update_6203() {
  $ret = array();
  db_change_field($ret, 'captcha_points', 'type', 'captcha_type', array('type' => 'varchar', 'length' => 64));
  return $ret;
}

which was written for Drupal 6. However, in Drupal 7, the db_change_field function changed its argument list (also see http://api.drupal.org/api/drupal/includes--database.pgsql.inc/function/d...):

// D6
db_change_field(&$ret, $table, $field, $field_new, $spec, $new_keys = array())
// D7
db_change_field($table, $field, $field_new, $spec, $keys_new = array())

This means that the original update function captcha_update_6203 should be run on a Drupal 6 setup before upgrading to a Drupal 7 setup.

Possible solutions:
* make a 6.x-2.4 release and document that users should first update to 6.x-2.4 before upgrading to Drupal 7
* change the upgrade function captcha_update_6203: detect if we are running on a D7 setup and call the db_change_field function accordingly.

soxofaan’s picture

FYI: I changed the upgrade note on the release notes of CAPTCHA 7.x-1.0-alpha2 to indicate that upgrade from D6 doesn't work currently.

soxofaan’s picture

Title: Upgrade from version 6.x-2.3 (D6) to 7.x-1.0-alpha2 (D7) failed » Prevent upgrading directly from 6.x-2.3 to 7.x-1.x
Category: bug » feature
Priority: Critical » Major

I just released CAPTCHA 6.x-2.4 and updated the upgrade info for 7.x-1.0-alpha2 that it is required to first upgrade to 6.x-2.4 before upgrading to 7.x-1.x. This seems to be standard upgrade procedure. Tweaking/porting the hook_update_N functions apparently is not recommended.

Also, I learned on IRC that with hook_update_last_removed, one can force to first upgrade to a certain D6 version before upgrading to a D7 version: in the D7 version of captcha.install, remove all D6 upgrade functions and implement hook_update_last_removed, returning the number of the last D6 update function. If the user did not upgrade to the latest D6 version first, he won't be able to upgrade to D7.
I have to look into this a bit more.

soxofaan’s picture

Title: Prevent upgrading directly from 6.x-2.3 to 7.x-1.x » Prevent upgrading directly from 6.x-2.3 (or earlier) to 7.x-1.x
xurizaemon’s picture

For congenitally lazy users of MySQL.

drush sqlq "alter table captcha_sessions add column token varchar(64)"
drush sqlq "alter table captcha_points change column type captcha_type varchar(64)"
drush sqlq "update system set schema_version = 6203 where name='captcha'"
drush updb
steinmb’s picture

Issue summary: View changes
Status: Active » Closed (outdated)