The upgrade timed out and now I have missing columns in the database

The upgrade timed out and now I have missing columns in the database

If during the upgrade process you get a timeout it is because your database is just too big and it takes too much time to run all the queries against your existing database.

In such case, the best is to restore your backup that you did before upgrading, and then do the upgrade again, this time from command line. If you don’t have a backup (you should though), then you might consider reinstalling the app, but if that’s not an option, what you can do, is to manually run all the queries that the upgrade process should have ran automatically for you.

AppMail stores its upgrade SQL files in /apps/common/data/update-sql/ folder and they are properly named after the version they upgrade to, so you will see files like 1.3.8.3.sql, 1.3.8.4.sql, 1.3.8.5.sql, 1.3.8.6.sql.
These are plain SQL files that can be ran against your database server. They don’t contain the table prefix (mw_ most likely) that you have selected during install, so you have to make sure that before executing these queries, you alter them properly so that you add their prefix.

So, let’s say you're app was at version 1.3.8.2, and you tried to upgrade to 1.3.8.6 and somewhere in the middle, the upgrade failed. We need to open the files 1.3.8.3.sql, 1.3.8.4.sql, 1.3.8.5.sql, 1.3.8.6.sql from /apps/common/data/update-sql/ and for each of the files, we have to manually run the queries from within (you can use the command line to run the queries or a tool like phpMyAdmin).
In this case, the files 1.3.8.3.sql and 1.3.8.4.sql are empty, so there’s nothing to do for them. However, 1.3.8.4.sql contains this:

--
-- Alter the campaign table
--
ALTER TABLE `campaign` CHANGE `subject` `subject` VARCHAR(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;

So we have to run this query using the command line or phpMyAdmin, but remember that first we have to add our selected table prefix to the above query. We will assume the prefix is mw_ so the above query becomes:

--
-- Alter the campaign table
--
ALTER TABLE `mw_campaign` CHANGE `subject` `subject` VARCHAR(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;

Now we can run it in phpMyAdmin and move on to next file. In this case, 1.3.8.5.sql and 1.3.8.6.sql are empty, so we are done with running the queries.
Last step we have to do, is to empty the application cache, that is, empty, or rename, the folder /apps/common/runtime/cache.

    • Related Articles

    • Update failure - Missing database table or columns

      You can get an error like: The table '{{table_name}}' for active record class 'ModelName' cannot be found in the database. Which means a database table is missing from your app, or you can get an error where the app complaints about a missing ...
    • Upgrade steps

      Before starting the update process, make sure you backup your files and database, this is very important. The upgrade process: Make sure you download latest version of AppMail and you don’t use the files from the same version you already have ...
    • Internal failure, maybe due to missing functions like proc_open!

      When validating a delivery server, and you get an error that says, “Internal failure, maybe due to missing functions like proc_open!” Most likely the issue is that AppMail cannot find a valid email template to send the validation email. To fix this, ...
    • Upgrading notes for AppMail 1.x to AppMail 2.x

      When upgrading from AppMail 1.x to AppMail 2.x there are a few things you need to do before starting the upgrade process. #1. It is very important you backup your application, be it on your own or by using the Backup Manager. #2. You need to disable ...
    • The IMAP extension is missing from your PHP installation.

      In case this kind of error isn’t pretty self-explanatory, your php instance doesn’t contain the imap extension. If you have access to command line, following commands should install php imap on your server: If you are on CentOS / RedHat / Fedora or ...