Ixonn Group

Preparing Module Upgrade

You are here:
< All Topics

To resolve an issue or improve your module, you want to create updates for your module so your customers can benefit from the enhancements.

Ixonn will determine whether there is a new upgrade for your module by the init file version header.

For example, you released a version 1.0.0 and the users are using this version, at the time the user will install your 1.0.0 version and activate the module, Ixonn will store the activated module version number in database.

Then you release version 1.1.0 and the user re-upload/install the module files, Ixonn will determine that the version from the file header is not the same like the one stored in the database and will show a message to the user to upgrade the database.

A screenshot of a cell phone

Description automatically generated

Ixonn modules migration extends the CodeIgniter framework migration library and uses the Sequential migration type, keep in mind that there is no ability to change the Sequential type to Timestamp.

If you are not familiar with the CodeIgniter migration library, the best is to check their documentation.

Each migration is numbered in sequence, starting with 001. Each number must be three digits, and there must not be any gaps in the sequence.

Create (if not exists) a folder name migrations in the module directory, after you create the folder the location will be: modules/[module-name]/migrations

For our example, you must create a migration file e.q. 110_version_110.php with the following contents:

<?php

 

defined(‘BASEPATH’) or exit(‘No direct script access allowed’);

 

class Migration_Version_110 extends App_module_migration

{

    public function up()

    {

        // Perform database upgrade here

    }

}

The 110_version_110.php file will perform an upgrade for your module version 1.1.0.

Keep in mind that in your activation hookyou still must have the latest changes for the database, the migration files will run only for existing installation who are using an older version, the new module installation must get these DB changes from the install hook.

Caveats

Downgrade

There is no ability to downgrade to previous versions, for this reason, always just add the up method in your migration files.

Create migration file whenever the module header version is changed.

You must create a migration file each time you change the module version number even if there are no changes in the database.

Ixonn can’t determine if you have or not have a database upgrades but the migration file must be executed in order just to upgrade the version number in database.

In cases like this when there is no queries to perform in the migration file, just leave the method up empty e.q. as shown in the example above.

The user will see that there is database upgrade required, will click “Upgrade Database”, an empty migration will run and the database number will be successfully updated.

Related Articles

Table of Contents
Scroll Up