error in upgrade

kvarnelis - March 2, 2006 - 06:44
Project:freelinking
Version:HEAD
Component:Code
Category:bug report
Priority:normal
Assigned:eafarris
Status:closed
Description

tried up upgrade freelinking module from earlier install.

blue bar showed up nicely and then...

ALTER TABLE {freelinking} DROP PRIMARY KEY
ALTER TABLE {freelinking} DROP COLUMN target
ALTER TABLE {freelinking} ADD COLUMN hash CHAR(32)
ALTER TABLE {freelinking} ADD COLUMN path VARCHAR(200)
ALTER TABLE {freelinking} ADD COLUMN args VARCHAR(200)
Failed: ALTER TABLE {freelinking} ADD PRIMARY KEY hash (hash)
DELETE FROM {freelinking}

under indexes, phpmyadmin reports:

Warning No index defined!

related?

#1

rar - May 6, 2006 - 15:47
Status:active» needs review

I also get the error - this is because if you actually had data in the freelinking
table you have all NULL's in the column "hash" and you can't have duplicates in creating
a primary key.

Also there is the command
$ret[] = update_sql('DELETE FROM {freelinking}');
Which erased all the freelinking data. (fortunately I made a backup before running the update)

I noticed that there was a command
$ret[] = update_sql('ALTER TABLE {freelinking} DROP COLUMN target');
before anything is done with the data in that column.

How about something like this in freelinking.install?

      $ret[] = update_sql('ALTER TABLE {freelinking} DROP PRIMARY KEY');
      $ret[] = update_sql('ALTER TABLE {freelinking} ADD COLUMN path VARCHAR(200)');
      $ret[] = update_sql('ALTER TABLE {freelinking} ADD COLUMN args VARCHAR(200)');
      $ret[] = update_sql('ALTER TABLE {freelinking} ADD COLUMN hash CHAR(32)');
      $ret[] = update_sql('UPDATE TABLE {freelinking} SET path = target;

      //do we need to concat in args? Its "NULL" at this point
      $ret[] = update_sql('UPDATE TABLE {freelinking} SET hash = md5(CONCAT(phrase,path));

      $ret[] = update_sql('ALTER TABLE {freelinking} DROP COLUMN target');
      $ret[] = update_sql('ALTER TABLE {freelinking} ADD PRIMARY KEY hash (hash)');

I haven't tested it - so UAOR

#2

eafarris - May 8, 2006 - 01:20
Assigned to:Anonymous» eafarris

Confirmed.

The DELETE should come before the key definition, I think. The DELETE FROM {freelinking} is a safe process, as there's nothing in that table that won't be recreated as your content gets viewed, and the caches get rebuilt after the upgrade.

That said, though, I'm not sure it's necessary. Rethinking. Your rewrite looks good.

Thanks for the report and evaluation.

#3

eafarris - May 8, 2006 - 13:54
Status:needs review» fixed

Committed a fix to CVS, based on the comments above. Thanks, rar!

#4

Anonymous - May 22, 2006 - 14:00
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.