static function install(Migration $migration)
{
global $DB;
$obj = new self();
$table = $obj->getTable();
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` INT(11) NOT NULL auto_increment,\n `name` VARCHAR(255) DEFAULT NULL,\n `label` VARCHAR(255) DEFAULT NULL,\n `type` VARCHAR(25) DEFAULT NULL,\n `plugin_fields_containers_id` INT(11) NOT NULL DEFAULT '0',\n `ranking` INT(11) NOT NULL DEFAULT '0',\n `default_value` VARCHAR(255) DEFAULT NULL,\n `is_active` TINYINT(1) NOT NULL DEFAULT '1',\n `is_readonly` TINYINT(1) NOT NULL DEFAULT '1',\n `mandatory` TINYINT(1) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n KEY `plugin_fields_containers_id` (`plugin_fields_containers_id`),\n KEY `is_active` (`is_active`),\n KEY `is_readonly` (`is_readonly`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}
$migration->displayMessage("Updating {$table}");
if (!FieldExists($table, 'is_active')) {
$migration->addField($table, 'is_active', 'bool', array('value' => 1));
$migration->addKey($table, 'is_active', 'is_active');
}
if (!FieldExists($table, 'is_readonly')) {
$migration->addField($table, 'is_readonly', 'bool', array('default' => false));
$migration->addKey($table, 'is_readonly', 'is_readonly');
}
if (!FieldExists($table, 'mandatory')) {
$migration->addField($table, 'mandatory', 'bool', array('value' => 0));
}
$migration->executeMigration();
return true;
}