Skip to content

Commit d0008a1

Browse files
caseysoftwareclaude
andcommitted
Report migration errors instead of silently dropping them
_applySQLUpdates() was meant to ignore only the errors you get when a migration re-adds a column or key that is already there. Two of its four checks were missing "=== false", so an error was reported only if its text contained both "Multiple primary key defined" and "Duplicate key name", which never happens. Every failed migration statement was dropped: the installer and System Admin > Upgrade always reported success, and installs could silently end up with a different schema (see the 012/033/050/051/056 fixes before this commit, all found this way). This is the "web2project just swallows them" behaviour noted on issue #385. - All four checks now use "=== false". - Dropping an index or column that is already gone ("check that it exists") is ignored too: the schema is already in the intended state, and 012 does this 23 times on a fresh install. - Each reported error starts with the migration file name. A fresh install now completes with no errors, and a failing statement in a new migration is listed on the upgrade page. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016CP89WVmGZ1VVCCZMS6ntN
1 parent 5d50ab9 commit d0008a1

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎classes/w2p/System/UpgradeManager.class.php‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,19 @@ protected function _applySQLUpdates($sqlfile, $dbConn) {
299299
/*
300300
* TODO: I'm not happy with this solution but have yet to come up
301301
* with another way of solving it...
302+
*
303+
* Adding a column or key that is already there, or dropping
304+
* one that is already gone, fails with one of these messages.
305+
* The schema is already in the intended state, so they are
306+
* ignored. Everything else is reported.
302307
*/
303308
if (strpos($errorMessage, 'Duplicate column name') === false &&
304309
strpos($errorMessage, 'column/key exists') === false &&
305-
strpos($errorMessage, 'Multiple primary key defined') &&
306-
strpos($errorMessage, 'Duplicate key name') ) {
310+
strpos($errorMessage, 'Multiple primary key defined') === false &&
311+
strpos($errorMessage, 'Duplicate key name') === false &&
312+
strpos($errorMessage, 'check that it exists') === false) {
307313

308-
$errorMessages[] = $errorMessage;
314+
$errorMessages[] = basename($sqlfile) . ': ' . $errorMessage;
309315
}
310316
}
311317
}

0 commit comments

Comments
 (0)