When upgrading to 7.x-1.2 I get the following error during updb:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'engagement_score' cannot be null
Performed update: redhen_engagement_update_7101
The problem lies in the UPDATE statement:
UPDATE redhen_contact rc SET engagement_score = (SELECT SUM(score) FROM redhen_engagement re JOIN redhen_engagement_score res on re.engagement_score = res.name WHERE re.contact_id = rc.contact_id)
The inner select return NULL if there is no engagements logged for a contact. Locally I've solved this by adding an COALESCE(…, 0) around the inner select.
The statement takes a long time for larger databases (perhaps due to the inner select). Maybe it's better to use a JOIN and avoid NULL values altogether.
Comments
Comment #1
torotil commentedI've found a rather dumb reason for the performance issues (in my drupal setup).
Here's a patch that fixes this bug by introducing COALESCE().
Comment #2
torotil commentedHere is a patch that makes it possible to rerun the failed (perhaps due to this bug) update hook.
Comment #3
alicemoon commentedthanks torotil - I had the same problem and your patch allowed my site to update properly.
Comment #4
levelos commentedThanks torotil, committed in 832217f.