This pages documents the MantisBT schema definition script (admin/schema.php), and explains how to modify it.
The schema is defined as a numbered list of updates (aka upgrade steps), stored as an array. Each step consists of two elements:
The schema's integrity relies on strict ordering of this array.
Release markers are placed right AFTER the last schema step that is included in the corresponding release:
$g_upgrade[173] = array( 'AddColumnSQL', array( db_get_table( 'bug_file' ), " user_id I UNSIGNED NOTNULL DEFAULT '0' " ) ); # Release marker: 1.2.0rc1 $g_upgrade[174] = array( 'DropColumnSQL', array( db_get_table( 'custom_field' ), 'advanced' ) );
In the above example, steps up to 173 are part of 1.2.0rc1, while 174 and onwards are included in 1.2.0rc2.
This section documents available upgrade operations:
CreateTableSQL
, ChangeTableSQL
, RenameTableSQL
, DropTableSQL
,AddColumnSQL
, AlterColumnSQL
, RenameColumnSQL
, DropColumnSQL
,CreateIndexSQL
, DropIndexSQL
InsertData
UpdateFunction
: local function to perform arbitrary changesnull
: no-op upgrade stepLocal function to add data to a table.
UpdateFunction
allows arbitrary PHP code to be executed via a function, which must be defined in install_helper_functions_api.php with an install_
prefix.
Example 1: Simple function without arguments
$g_upgrade[186] = array( 'UpdateFunction', 'update_history_long_custom_fields' );
function install_update_history_long_custom_fields() { # [... function code ...] }
Example 2: function with arguments
/** * Migrate the legacy date format. * @param array $p_data Array: [0] = tablename, [1] id column, [2] = old column, [3] = new column. * @return integer */ function install_date_migrate( array $p_data ) { # [... function code ...] }
No-op upgrade step. The installer will do nothing.
This is used to skip the step while maintaining the upgrade sequence, e.g. when an operation becomes obsolete or doesn't apply for specific cases.