• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Need some help with upgrading the install file of my add on

wang

Well-known member
#1
Hello,

I have made some changes to several tables for my articles manager add on, but the upgrader for the new version does not carry those changes to the new version.

I am following Resource Manager add on 's install and upgrade example, but it is not working for me. The current version id of the add on is 121. For the new version I had 20, but upon upgrade I got an error message saying that this version was older than the one that I was trying to upgrade from. So I changed it to 200. The upgrade did go fine, but the new database changes were not added. This is what I have.

PHP:
public static function install($previous)
    {
        $db = XenForo_Application::get('db');

        if (!$previous)
        {
            foreach (self::getTables() AS $tableName => $tableSql)
            {
                try
                {
                    $db->query($tableSql);
                }
                catch (Zend_Db_Exception $e) {}
            }

            foreach (self::getAlters() AS $tableName => $alterSql)
            {
                try
                {
                    $db->query($alterSql);
                }
                catch (Zend_Db_Exception $e) {}
            }

            foreach (self::getData() AS $tableName => $dataSql)
            {
                $db->query($dataSql);
            }
        }
        else
        {
            // upgrades
            if ($previous['version_id'] < 200)
            {
                try
                {
                    $db->query("
                        ALTER TABLE xf_table_name
                          CHANGE old_field new_field int(10) unsigned NOT NULL auto_increment,
                          ADD new_field_name blob NOT NULL,                     
                    ");
                }
                catch (Zend_Db_Exception $e) {}
               
            }
        }
    }
What I am doing wrong? I have been working on this for hours now and no luck so far. I have tried different variations with the version id, but the result has been the same. Some help will be much appreciated.
 

Lawrence

Well-known member
#2
$db->query("
ALTER TABLE xf_table_name
CHANGE old_field new_field int(10) unsigned NOT NULL auto_increment,
ADD new_field_name blob NOT NULL,
");

Most likely the comma after NOT NULL
 

wang

Well-known member
#4
$db->query("
ALTER TABLE xf_table_name
CHANGE old_field new_field int(10) unsigned NOT NULL auto_increment,
ADD new_field_name blob NOT NULL,
");

Most likely the comma after NOT NULL
The query is erroring. There shouldn't be a trailing comma after blob NOT NULL

What he said ^^
Many many thanks to both of you. I can not believe that I had missed that.