XF 2.3 Errors when upgrading from 2.2.16-Patch-2 to 2.3 RC2 --- LogicException: xf_job: priority already exists in table, but cannot change length in src/XF

CZ Eddie

Active member
Tried upgrading 2.1.2 to 2.2.16-Patch-2 and then to 2.3 RC2 but got these errors:

1718048479679.webp

Tried a couple things and then got this error on the next upgrade attempt:
1718048523367.webp


Code:
LogicException: xf_job: priority already exists in table, but cannot change length in src/XF/Db/Schema/Column.php at line 381
[LIST=1]
[*]XF\Db\Schema\Column->getDefinition() in src/XF/Db/Schema/Alter.php at line 238
[*]XF\Db\Schema\Alter->getQueries() in src/XF/Db/Schema/AbstractDdl.php at line 154
[*]XF\Db\Schema\AbstractDdl->apply() in src/XF/Db/SchemaManager.php at line 154
[*]XF\Db\SchemaManager->alterTable() in src/XF/Install/Upgrade/2030034-230b4.php at line 22
[*]XF\Install\Upgrade\Version2030034->step1() in src/XF/Install/Controller/Upgrade.php at line 180
[*]XF\Install\Controller\Upgrade->actionRun() in src/XF/Mvc/Dispatcher.php at line 352
[*]XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 263
[*]XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
[*]XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
[*]XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2607
[*]XF\App->run() in src/XF.php at line 533
[*]XF::runApp() in install/index.php at line 14

Went back to command line upgrade and got this error:
1718048549320.webp

Any suggestions?
 
Solution
Fixed

Something to do with the upgrade script trying to add a priority column to the xf_job table but it already exists, so the upgrade fails when the script tries to add it again.

Modify Step 1 of the script like this:

Code:
public function step1()
{
    $sm = $this->schemaManager();
    $db = $this->db();

    // Check if the column exists
    $columnExists = $db->fetchOne("SHOW COLUMNS FROM xf_job LIKE 'priority'");

    // Only add the column if it doesn't exist
    if (!$columnExists) {
        $sm->alterTable('xf_job', function (Alter $table)
        {
            $table->addColumn('priority', 'smallint', 5)->setDefault(100);
            $table->addKey(['priority', 'trigger_date'], 'priority_execute_date');
        });
    }
}
Fixed

Something to do with the upgrade script trying to add a priority column to the xf_job table but it already exists, so the upgrade fails when the script tries to add it again.

Modify Step 1 of the script like this:

Code:
public function step1()
{
    $sm = $this->schemaManager();
    $db = $this->db();

    // Check if the column exists
    $columnExists = $db->fetchOne("SHOW COLUMNS FROM xf_job LIKE 'priority'");

    // Only add the column if it doesn't exist
    if (!$columnExists) {
        $sm->alterTable('xf_job', function (Alter $table)
        {
            $table->addColumn('priority', 'smallint', 5)->setDefault(100);
            $table->addKey(['priority', 'trigger_date'], 'priority_execute_date');
        });
    }
}
 
Solution
Back
Top Bottom