Closed (fixed)
Project:
Date
Version:
6.x-2.3
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
29 Jul 2009 at 22:12 UTC
Updated:
14 Apr 2010 at 20:53 UTC
Jump to comment: Most recent file
There is an error when upgrading from 2.2 to 2.3
You renamed the table with an 's' but the old constraint does not have an 's'.
I think that if you were to drop the old constraint, rename the table, then create the new one, then it would work.
Update #6004
* ALTER TABLE {date_format} RENAME TO {date_formats}
* Failed: ALTER TABLE {date_formats} DROP CONSTRAINT {date_formats}_format_key
* ALTER TABLE {date_formats} ADD CONSTRAINT {date_formats}_formats_key UNIQUE (format,type)
I had a constraint named 'date_format_format_key'.
Thank you.
Alexis Wilke
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 535008-date_api.install.patch | 429 bytes | neilnz |
Comments
Comment #1
hawk259 commentedHad the same problem and I agree with the fix, here is a patch:
Comment #2
Leeteq commentedMarked as duplicate:
http://drupal.org/node/535270
Comment #3
AlexisWilke commentedIt seems to me that 535270 is different in that I did not have any lock up problem. Now if this fix works on all cases, then that's the same 8-)
Alexis
Comment #4
David_Rothstein commentedI agree that the other issue is different - not a duplicate. This issue was marked as "minor" originally so I'm putting it back (is that correct? - are there any other side effects that result from this, or is just an error on the screen?).
By the way, I couldn't reproduce this on MySQL, and from the format of the above queries it looks like they came from Postgres. Maybe this bug is specific to Postgres.... The proposed fix looks like it makes sense - can you submit it as a patch?
Comment #5
AlexisWilke commentedDavid,
#1 is a patch, although it was pasted here instead of attaching a file. You can create a patch by copying #1 in a text file and saving it.
Also, it may indeed be specific to postgresql. I do indeed use that db. 8-)
Thank you.
Alexis
Comment #6
neilnz commentedAttached hawk259's patch as a file.
I can confirm this fixes the problem on Postgres for me as well.
Comment #7
neilnz commentedOh, and although the effect is somewhat minor, it's not just an error, the end result is that there are two unique constraints on date_formats for (format, type), one called date_formats_format_key and date_format_format_key. This may have slight performance implications (double-indexed) and may lead to trouble with future updates that assume that there's only the one constraint.
Here's what the Postgres table definition looked like after the failure:
At this point I think it may have happened to enough people that a future update hook should search for a constraint named date_format_format_key and remove it if it's there, just to be safe.
Comment #8
AlexisWilke commentedneilnz,
Good point. Also I took care of checking every DB, most people aren't as tecky... 8-)
Thank you.
Alexis
Comment #9
karens commentedThis is definitely not a problem for MYSQL, I have done numerous updates with no problem in MYSQL. And I also checked whether MYSQL ends up with duplicate keys and it does not, so that issue also does not seem to affect MYSQL.
I will add the above patch, but am not sure about what a patch to look for duplicate keys might look like, since it should not make any changes in MYSQL, which ends up correctly configured. If someone provides a patch for that and confirms it does not break anything in MYSQL I will commit it.
Comment #10
neilnz commentedI don't believe MySQL does named constraints, so it's a NOOP on MySQL I guess.
I'm not sure that Drupal provides a way to detect whether a constraint exists, so you might just have to blindly drop it in an update hook and if it fails, ignore it. You could do something like:
So it only shows up in the update log if it was successful.
Comment #11
neilnz commentedSorry that last code was nonsense, better:
Or something along those lines.