This is an old revision of the document!
Table of Contents
MantisBT Database Schema
This pages documents the MantisBT schema definition script (admin/schema.php), and explains how to modify it.
Introduction
The schema is defined as a numbered list of updates (aka upgrade steps), stored as an array. Each step consists of two elements:
- A function to generate SQL statements. Available operations are described in Upgrade Functions section below
- An array of parameters to be passed to the function.
The integrity of the schema relies on strict ordering of this array.
- ONLY ADD NEW CHANGES TO THE END OF THE TABLE!!!
Always specify the schema step (array key), for documentation purposes - NEVER SKIP AN INDEX IN THE SEQUENCE!!!
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.
Upgrade functions
This section documents available upgrade operations:
- Data dictionary operations from ADOdb library; one of:
- Tables:
CreateTableSQL
,ChangeTableSQL
,RenameTableSQL
,DropTableSQL
, - Columns:
AddColumnSQL
,AlterColumnSQL
,RenameColumnSQL
,DropColumnSQL
, - Indexes:
CreateIndexSQL
,DropIndexSQL
InsertData
UpdateFunction
: local function to perform arbitrary changesnull
: no-op upgrade step
CreateTableSQL
ChangeTableSQL
RenameTableSQL
DropTableSQL
AddColumnSQL
AlterColumnSQL
RenameColumnSQL
DropColumnSQL
CreateIndexSQL
DropIndexSQL
InsertData
Local function to add data to a table.
UpdateFunction
UpdateFunction
allows arbitrary PHP code to be executed via a function, which must be defined in install_helper_functions_api.php with install_
prefix.
null
No-op upgrade step.
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.