How to make automatic upgrade script for module

There is a prepared zip package with the simplest update for Dolphin 7 module here. Download it, unpack and upload to the modules/me/bloggie/updates/ folder. bloggie folder is the root folder of Bloggie module which was described here, updates folder is a folder for all updates for Bloggie module, if it doesn't exist then you need to create it.

The zip package contains update_100_110 folder. It is up to you how to name the folder but it is a good practice to include "version from" and "version to" into the folder name, it is just more clear. Lets describe each file in the update. This is almost the minimal set of files for the module's update:

Update installation directory, where all installation files are located, like SQL files and language files.
Update installation config file. We will take a closer look at this later.
Update installer class. You can add some custom installation scripts and override default behaviour.
Installation information messages folder. If you need to display information messages upon update install, you will need to place files here - also special instructions are needed to point to in the install config file to display these messages properly.

'install' => array(
	'show_introduction' => 1,
	'show_conclusion' => 1

Update languages must be located in this dir. The language file must be a php file with the name of two letters of the language code. We will take a closer look at an example of the language file later.
An update for default English language file.
SQL script for update install is here.
Update installation SQL file.
A folder with files and folders which should be uploaded in module's folder. So, files and folders structure should match module's one. You may read more about module's file structure here.

Configuration file.

Module's update script has its own config.php file. The main differences between module's and update's configuration files are listed below. Update's configuration file has the following additional parameters

  1. Config file should specify the version which it can be applied to. Also it should specify the version which you'll have after the update was applied.
    'version_from' => '1.0.0',
    'version_to' => '1.1.0',
  2. Home directory and URI of the module which the update relates to.
    'module_dir' => 'me/bloggie/',
    'module_uri' => 'bloggie',

Update's configuration file doesn't have the following parameters in comparison with module's config file.

  1. Everything related to uninstallation.
    	'uninstall' => array (
    	'uninstall_permissions' => array(),
    	'uninstall_info' => array(
    		'introduction' => 'uninst_intro.html',
    		'conclusion' => 'uninst_concl.html'
  2. Dependencies settings.
    'dependencies' => array(),

Language file.

In comparison with module's language file update's language file has three separate arrays.

  1. An array for language keys which should be deleted. The array should contain language keys only.
$aLangContentDelete = array(
  1. An array for language keys which should be added. The array should contain key => translation pairs.
$aLangContentAdd = array(  
	'_language_key' => 'translation'
  1. An array for language keys which should be updated. The array should contain key => translation pairs.
$aLangContentUpdate = array(
	'_language_key' => 'translation',

The feature works correctly since version 7.1.4.

How to enable automatic checking for module updates

  1. You need to use URL like the following in module's update_url parameter in install/config.php file.[UNIQUE_MODULE_NAME]

UNIQUE_MODULE_NAME is a unique module identifier. You may use some personal prefix for your modules.

  1. You need to enter the same UNIQUE_MODULE_NAME during uploading a product in BoonEx Market. It should be specified in mandatory field Courtesy Info -> Name
  1. You need to upload update script in BoonEx Market product. You may do it using updated files uploader File uploader in BoonEx Market product.

Note. If, for example, you want to upload upgrade script from version 1.0.0 to version 2.0.0 then both of these versions should be already uploaded in the product.

Last modified 11 years ago Last modified on Jul 23, 2013, 8:01:31 AM

Attachments (2)

Download all attachments as: .zip

Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.
Fork me on GitHub