XF 2.2 Why is my addon skipping the upgrade steps?

CStrategies

Active member
In my setup.php I have:

PHP:
namespace My/Addon;

use XF\AddOn\AbstractSetup;

use XF\AddOn\StepRunnerInstallTrait;

use XF\AddOn\StepRunnerUninstallTrait;

use XF\AddOn\StepRunnerUpgradeTrait;

use XF\Db\Schema\Alter;

use XF\Db\Schema\Create;

class Setup extends AbstractSetup

{

    use StepRunnerInstallTrait;

    use StepRunnerUninstallTrait;

    use StepRunnerUpgradeTrait;

    public function installStep1()

    {

        $this->schemaManager()->createTable('my_table', function(Create $table)

    ....

When I installed this through the ACP, it correctly created the table 'my_table'.

I built the next version of my addon using:
Code:
xf-addon:bump-version My/Addon --version-id 1003010
xf-addon:build-release My/Addon

Then, I added this to setup:

PHP:
    public function upgrade1004010Step1()

    {

        $this->schemaManager()->alterTable('my_table', function(Alter $table)

    ...

    }

    public function upgrade1004010Step2()

    {

        $this->schemaManager()->createTable('new_table', function(Create $table)

        {

    ...

Then, bumped and built:

Code:
xf-addon:bump-version My/Addon --version-id 1004010
xf-addon:build-release My/Addon

At this point, I would have thought I would see the new tables in the database, but it appears the steps were skipped. I thought maybe the version needs to be higher than the one in setup, so I tried bumping and building again:

Code:
xf-addon:bump-version My/Addon --version-id 1005010
xf-addon:build-release My/Addon

Didn't work. Tried rebuilding the addon from the ACP. Didn't work. Any ideas? Thank you!
 
So, after some trial and error I think I solved this issue.

Apparently, when running the BumpVersion command through CLI, this does not trigger any upgrade steps in the setup of the addon.

I may be not be doing this the intended way, but my solution was to uninstall the addon in the ACP, then install from a previous version release zip file. Then upgrade through the ACP using the most recent version's release zip. This triggered all of the appropriate upgrade steps.

My conclusion is that CLI BumpVersion is only for development purposes and can't be used to test upgrade steps in the setup.php. I do see that I can manually trigger upgrade steps through the CLI, which I suppose would be the way to go in the future if I've already bumped the version.
 
So, just tried this method with an addon that has a build.json file to include js script files, and for some reason that made things break again. With the build.json file in the folder, for some reason trying to install any older version causes XF to install the older version's files and templates, but automatically upgrade the version number to the latest version. What??

Oh, and it erased all my work since the previous version. Nice.
 
Last edited:
Back
Top Bottom