WHMCS Upgrade Failure: Unable to complete incremental updates

WHMCS Upgrade Error

While attempting to upgrade WHMCS version 5.x to 7.x, I kept getting MySQL errors from the updater script, and here’s how I was able to fix it.

The Errors

The first few errors I kept getting looked like this, saying table tblupdatehistory聽 already exists:

So as you would think, I just went ahead and dropped that table, but then one after another I kept getting errors about the聽 created_at聽 and聽 updated_at聽columns already existing, something like this:

The Problem

The problem stems from the fact聽that WHMCS doesn’t care enough to spend the time to write a sql script that will actually check if those columns, or tables exist, before running the commands. 聽Basically that means, if you have any type of error during your upgrade, they EXPECT YOU聽to restore a copy of the database, instead of writing a sql script that actually checks for columns before attempting to ALTER the table and add the column. 聽So as usual, I had to come up with my own solution to their sloppy sql scripts.

The Solution

To determine the exact solution I needed to come up with, I had to inspect the sql upgrade file they were trying to import that was throwing the errors. 聽The specific file ended up being the upgrade600alpha1.sql聽聽file, that’s where I found the MySQL code that was attempting to ALTER聽 the table and ADD COLUMN聽 without actually checking if the column already exists (that’s after the code that attempts to add the tblupdatehistory聽 table without checking that it exists).

In order to get the upgrade to complete all the way, I had to literally fix each error one at a time as it showed on the upgrade page, and at the end, this is the MySQL code I had to run through phpMyAdmin to get past those errors:

As you can see, I first drop the tables that are created by the upgrade database file, then drop the columns that are added by that file as well. 聽You will notice that the port column is also dropped, as this is added by the MySQL import as well. 聽Once I did this, and resolved a few other issues (I also had to add userid聽 column to tblinvoiceitems聽 as well), and voila! 聽Profit!

If you want to see what tables have a specific column in them, you can run this command and it will return the tables the column is found in:

Example Errors

 

Myles

Orlando, FL

Did this post help you?

Give back and rate it for me!

Related Posts

  • Andry

    Can you put all the code?
    Thanks