Bad data in the DB can cause the schema correction SQL to throw a fatal error

Bug #1262932 reported by Aaron Wells
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Aaron Wells
1.8
Fix Released
Medium
Aaron Wells

Bug Description

Looking at this forum post https://mahara.org/interaction/forum/topic.php?id=5986&offset=0&limit=10 ...

It occurs to me that there's a problem in our schema correction code. We're adding foreign keys to existing tables, but we didn't first check to see whether the tables have data that will fit that foreign key. If they have bad data, then this upgrade script will error out and prevent them from upgrading. And since these missing schema elements are not vital, we don't want their failure to block upgrade.

We should have put a "catch (SQLException $e)" block around each attempt to add a foreign key, unique index, and/or primary key, or another other schema element that will fail if their data isn't clean. :-P

Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :
Changed in mahara:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Aaron Wells (u-aaronw)
milestone: none → 1.9.0
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/2833
Committed: http://gitorious.org/mahara/mahara/commit/2df7d4eab0b9495f6501cc4e4048f801fa92f313
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 2df7d4eab0b9495f6501cc4e4048f801fa92f313
Author: Aaron Wells <email address hidden>
Date: Fri Dec 20 13:41:05 2013 +1300

Bug 1262932: Let upgrade proceed even if schema drift can't be corrected

In 1.8.1 we added some code to correct schema drift in Mahara sites that
were originally installed with 1.2.0 or earlier. But, these schema
corrections can fail if the tables contain data that violates the
constraints we're trying to add.

This update changes that failure from a fatal error, to a warning.

Change-Id: I51989b276642b8d1b7b55813aa33df86f1e52a5c

Aaron Wells (u-aaronw)
Changed in mahara:
status: In Progress → Fix Committed
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "1.8_STABLE" branch: https://reviews.mahara.org/2906

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/2906
Committed: http://gitorious.org/mahara/mahara/commit/c1f0d5dba1fece6d76b25cf0b1559105b5478b8e
Submitter: Aaron Wells (<email address hidden>)
Branch: 1.8_STABLE

commit c1f0d5dba1fece6d76b25cf0b1559105b5478b8e
Author: Aaron Wells <email address hidden>
Date: Fri Dec 20 13:41:05 2013 +1300

Bug 1262932: Let upgrade proceed even if schema drift can't be corrected

In 1.8.1 we added some code to correct schema drift in Mahara sites that
were originally installed with 1.2.0 or earlier. But, these schema
corrections can fail if the tables contain data that violates the
constraints we're trying to add.

This update changes that failure from a fatal error, to a warning.

Change-Id: I51989b276642b8d1b7b55813aa33df86f1e52a5c

Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.