Posted by kvarnelis on March 2, 2006 at 6:44am
Jump to:
| Project: | freelinking |
| Version: | master |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | eafarris |
| Status: | closed (fixed) |
Issue Summary
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?
Comments
#1
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
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
Committed a fix to CVS, based on the comments above. Thanks, rar!
#4