本文整理汇总了PHP中Migration::addKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::addKey方法的具体用法?PHP Migration::addKey怎么用?PHP Migration::addKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Migration
的用法示例。
在下文中一共展示了Migration::addKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
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;
}
示例2: install
public static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL DEFAULT '0',\n `is_recursive` tinyint(1) NOT NULL DEFAULT '1',\n `name` varchar(255) NOT NULL DEFAULT '',\n `comment` text collate utf8_unicode_ci,\n `color` varchar(50) NOT NULL DEFAULT '' COLLATE 'utf8_unicode_ci',\n PRIMARY KEY (`id`),\n KEY `name` (`name`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error());
}
if (!FieldExists($table, 'type_menu')) {
$migration->addField($table, 'type_menu', "varchar(50) NOT NULL DEFAULT ''");
$migration->addKey($table, 'type_menu');
$migration->migrationOneTable($table);
}
// Version 0.90-1.1
$result = $DB->query("SHOW FIELDS FROM `{$table}` where Field ='type_menu'");
if ($result && $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
if (stristr($data["Type"], 'varchar') !== FALSE) {
$DB->query("ALTER TABLE `{$table}` DROP INDEX `type_menu`;");
$DB->query("ALTER TABLE `{$table}` MODIFY `type_menu` text COLLATE utf8_unicode_ci;");
$datas = getAllDatasFromTable($table, "`type_menu` IS NOT NULL");
if (!empty($datas)) {
foreach ($datas as $data) {
$itemtypes = PluginTagTagItem::getItemtypes($data['type_menu']);
$DB->query("UPDATE `{$table}` SET `type_menu` = '" . json_encode($itemtypes) . "' WHERE `id` = '" . $data['id'] . "'");
}
}
break;
}
}
}
return true;
}
示例3: install
public static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
//Installation
if (!TableExists($table) && !TableExists("glpi_plugin_order")) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_orders` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_template` tinyint(1) NOT NULL default '0',\n `template_name` varchar(255) collate utf8_unicode_ci default NULL,\n `is_recursive` tinyint(1) NOT NULL default '0',\n `name` varchar(255) collate utf8_unicode_ci default NULL,\n `num_order` varchar(255) collate utf8_unicode_ci default NULL,\n `budgets_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_budgets (id)',\n `plugin_order_ordertaxes_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_ordertaxes (id)',\n `plugin_order_orderpayments_id` int (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orderpayments (id)',\n `order_date` date default NULL,\n `duedate` date default NULL,\n `deliverydate` date default NULL,\n `is_late` tinyint(1) NOT NULL default '0',\n `suppliers_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)',\n `contacts_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_contacts (id)',\n `locations_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_locations (id)',\n `plugin_order_orderstates_id` int(11) NOT NULL default 1,\n `plugin_order_billstates_id` int(11) NOT NULL default 1,\n `port_price` float NOT NULL default 0,\n `comment` text collate utf8_unicode_ci,\n `notepad` longtext collate utf8_unicode_ci,\n `is_deleted` tinyint(1) NOT NULL default '0',\n `users_id` int(11) NOT NULL default '0',\n `groups_id` int(11) NOT NULL default '0',\n `users_id_delivery` int(11) NOT NULL default '0',\n `groups_id_delivery` int(11) NOT NULL default '0',\n `plugin_order_ordertypes_id` int (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_ordertypes (id)',\n `date_mod` datetime default NULL,\n `is_helpdesk_visible` tinyint(1) NOT NULL default '1',\n PRIMARY KEY (`id`),\n KEY `name` (`name`),\n KEY `entities_id` (`entities_id`),\n KEY `plugin_order_ordertaxes_id` (`plugin_order_ordertaxes_id`),\n KEY `plugin_order_orderpayments_id` (`plugin_order_orderpayments_id`),\n KEY `states_id` (`plugin_order_orderstates_id`),\n KEY `suppliers_id` (`suppliers_id`),\n KEY `contacts_id` (`contacts_id`),\n KEY `locations_id` (`locations_id`),\n KEY `is_late` (`locations_id`),\n KEY `is_template` (`is_template`),\n KEY `is_deleted` (`is_deleted`),\n KEY date_mod (date_mod)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
Crontask::Register(__CLASS__, 'computeLateOrders', HOUR_TIMESTAMP, array('param' => 24, 'mode' => CronTask::MODE_EXTERNAL));
} else {
//Upgrade
$migration->displayMessage("Upgrading {$table}");
if (TableExists('glpi_plugin_order')) {
//Update to 1.1.0
$migration->addField('glpi_plugin_order', "port_price", "FLOAT NOT NULL default '0'");
$migration->addField('glpi_plugin_order', "taxes", "FLOAT NOT NULL default '0'");
if (FieldExists("glpi_plugin_order", "numordersupplier")) {
foreach ($DB->request("glpi_plugin_order") as $data) {
$query = "INSERT INTO `glpi_plugin_order_suppliers`\n (`ID`, `FK_order`, `numorder`, `numbill`) VALUES\n (NULL, '" . $data["ID"] . "', '" . $data["numordersupplier"] . "', '" . $data["numbill"] . "') ";
$DB->query($query) or die($DB->error());
}
}
$migration->dropField('glpi_plugin_order', 'numordersupplier');
$migration->dropField('glpi_plugin_order', 'numbill');
$migration->migrationOneTable('glpi_plugin_order');
}
//1.2.0
$domigration_itemtypes = false;
if ($migration->renameTable("glpi_plugin_order", $table)) {
$domigration_itemtypes = true;
}
$migration->changeField($table, "ID", "id", "int(11) NOT NULL AUTO_INCREMENT");
$migration->changeField($table, "FK_entities", "entities_id", "int(11) NOT NULL default 0");
$migration->changeField($table, "recursive", "is_recursive", "tinyint(1) NOT NULL default 0");
$migration->changeField($table, "name", "name", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->changeField($table, "budget", "budgets_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_budgets (id)'");
$migration->changeField($table, "numorder", "num_order", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->changeField($table, "taxes", "plugin_order_ordertaxes_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_ordertaxes (id)'");
$migration->changeField($table, "payment", "plugin_order_orderpayments_id", "int (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orderpayments (id)'");
$migration->changeField($table, "date", "order_date", "date default NULL");
$migration->changeField($table, "FK_enterprise", "suppliers_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)'");
$migration->changeField($table, "FK_contact", "contacts_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_contacts (id)'");
$migration->changeField($table, "location", "locations_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_locations (id)'");
$migration->changeField($table, "status", "states_id", "int(11) NOT NULL default '0'");
$migration->changeField($table, "comment", "comment", "text collate utf8_unicode_ci");
$migration->changeField($table, "notes", "notepad", "longtext collate utf8_unicode_ci");
$migration->changeField($table, "deleted", "is_deleted", "tinyint(1) NOT NULL default '0'");
$migration->addKey($table, "name");
$migration->addKey($table, "entities_id");
$migration->addKey($table, "plugin_order_ordertaxes_id");
$migration->addKey($table, "plugin_order_orderpayments_id");
$migration->addKey($table, "states_id");
$migration->addKey($table, "suppliers_id");
$migration->addKey($table, "contacts_id");
$migration->addKey($table, "locations_id");
$migration->addKey($table, "is_deleted");
$migration->migrationOneTable($table);
//Only migrate itemtypes when it's only necessary, otherwise it breaks upgrade procedure !
if ($domigration_itemtypes) {
Plugin::migrateItemType(array(3150 => 'PluginOrderOrder'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array());
}
if (TableExists("glpi_plugin_order_budgets")) {
//Manage budgets (here because class has been remove since 1.4.0)
$migration->changeField("glpi_plugin_order_budgets", "ID", "id", " int(11) NOT NULL auto_increment");
$migration->changeField("glpi_plugin_order_budgets", "FK_entities", "entities_id", "int(11) NOT NULL default '0'");
$migration->changeField("glpi_plugin_order_budgets", "FK_budget", "budgets_id", "int(11) NOT NULL default '0'");
$migration->changeField("glpi_plugin_order_budgets", "comments", "comment", "text collate utf8_unicode_ci");
$migration->changeField("glpi_plugin_order_budgets", "deleted", "is_deleted", "tinyint(1) NOT NULL default '0'");
$migration->changeField("glpi_plugin_order_budgets", "startdate", "start_date", "date default NULL");
$migration->changeField("glpi_plugin_order_budgets", "enddate", "end_date", "date default NULL");
$migration->changeField("glpi_plugin_order_budgets", "value", "value", "float NOT NULL DEFAULT '0'");
$migration->addKey("glpi_plugin_order_budgets", "entities_id");
$migration->addKey("glpi_plugin_order_budgets", "is_deleted");
$migration->migrationOneTable("glpi_plugin_order_budgets");
Plugin::migrateItemType(array(3153 => 'PluginOrderBudget'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array());
//Manage budgets migration before dropping the table
$budget = new Budget();
$matchings = array('budgets_id' => 'id', 'name' => 'name', 'start_date' => 'begin_date', 'end_date' => 'end_date', 'value' => 'value', 'comment' => 'comment', 'entities_id' => 'entities_id', 'is_deleted' => 'is_deleted');
foreach (getAllDatasFromTable("glpi_plugin_order_budgets") as $data) {
$tmp = array();
$id = false;
foreach ($matchings as $old => $new) {
if (!is_null($data[$old])) {
$tmp[$new] = $data[$old];
}
}
$tmp['comment'] = Toolbox::addslashes_deep($tmp['comment']);
//Budget already exists in the core: update it
if ($budget->getFromDB($data['budgets_id'])) {
$budget->update($tmp);
$id = $tmp['id'];
} else {
//Budget doesn't exists in the core: create it
unset($tmp['id']);
$id = $budget->add($tmp);
}
}
$DB->query("DROP TABLE `glpi_plugin_order_budgets`");
foreach (array('glpi_displaypreferences', 'glpi_documents_items', 'glpi_bookmarks', 'glpi_logs') as $t) {
//.........这里部分代码省略.........
示例4: updateSchema
static function updateSchema(Migration $migration)
{
$migration->displayTitle(sprintf(__('%1$s: %2$s'), __('Update'), self::getTypeName(9)));
$table = getTableForItemType(__CLASS__);
// Version 1.6.1
$migration->changeField($table, 'notes', 'notepad', 'text');
// Version 1.8.0
$migration->addKey($table, 'users_id');
$migration->addKey($table, 'groups_id');
$migration->addKey($table, 'plugin_appliances_appliancetypes_id');
$migration->addKey($table, 'plugin_appliances_environments_id');
$migration->addField($table, 'states_id', 'integer', array('after' => 'date_mod'));
$migration->addKey($table, 'states_id');
$migration->addField($table, 'users_id_tech', 'integer', array('after' => 'users_id'));
$migration->addKey($table, 'users_id_tech');
$migration->addField($table, 'groups_id_tech', 'integer', array('after' => 'groups_id'));
$migration->addKey($table, 'groups_id_tech');
}
示例5: install
public static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
if (!TableExists("glpi_plugin_order_suppliers")) {
$migration->displayMessage("Installing {$table}");
//install
$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_orders_suppliers` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_recursive` tinyint(1) NOT NULL default '0',\n `plugin_order_orders_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orders (id)',\n `suppliers_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)',\n `num_quote` varchar(255) collate utf8_unicode_ci default NULL,\n `num_order` varchar(255) collate utf8_unicode_ci default NULL,\n `num_bill` varchar(255) collate utf8_unicode_ci default NULL,\n PRIMARY KEY (`id`),\n KEY `plugin_order_orders_id` (`plugin_order_orders_id`),\n KEY `entities_id` (`entities_id`),\n KEY `suppliers_id` (`suppliers_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
} else {
//Upgrade
$migration->displayMessage("Upgrading {$table}");
//1.2.0
$migration->renameTable("glpi_plugin_order_suppliers", $table);
$migration->addField($table, "entities_id", "int(11) NOT NULL default '0'");
$migration->addField($table, "is_recursive", "tinyint(1) NOT NULL default '0'");
$migration->addField($table, "suppliers_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)'");
$migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
$migration->changeField($table, "FK_order", "plugin_order_orders_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orders (id)'");
$migration->changeField($table, "numquote", "num_quote", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->changeField($table, "numbill", "num_bill", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->changeField($table, "numorder", "num_order", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->addKey($table, "plugin_order_orders_id");
$migration->addKey($table, "suppliers_id");
$migration->migrationOneTable($table);
Plugin::migrateItemType(array(3154 => 'PluginOrderOrder_Supplier'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets"), array());
//1.5.0
$query = "SELECT `suppliers_id`, `entities_id`,`is_recursive`,`id`\n FROM `glpi_plugin_order_orders` ";
foreach ($DB->request($query) as $data) {
$query = "UPDATE `glpi_plugin_order_orders_suppliers` SET\n `suppliers_id` = '{$data["suppliers_id"]}'\n WHERE `plugin_order_orders_id` = '{$data["id"]}' ";
$DB->query($query) or die($DB->error());
$query = "UPDATE `glpi_plugin_order_orders_suppliers` SET\n `entities_id` = '{$data["entities_id"]}',\n `is_recursive` = '{$data["is_recursive"]}'\n WHERE `plugin_order_orders_id` = '{$data["id"]}' ";
$DB->query($query) or die($DB->error());
}
}
}
}
示例6: install
static function install(Migration $migration)
{
global $DB;
$table = 'glpi_plugin_webservices_clients';
$migration->renameTable('glpi_plugin_webservices', $table);
if (TableExists('glpi_plugin_webservices_clients')) {
$migration->changeField($table, 'ID', 'id', 'autoincrement');
$migration->changeField($table, 'FK_entities', 'entities_id', 'integer');
$migration->changeField($table, 'recursive', 'is_recursive', 'bool');
$migration->changeField($table, 'active', 'is_active', 'bool');
$migration->changeField($table, 'comments', 'comment', 'text');
$migration->changeField($table, 'FK_entities', 'entities_id', 'integer');
$migration->addField($table, 'deflate', 'bool', array('after' => 'is_active'));
$migration->addField($table, 'debug', 'bool', array('after' => 'do_log'));
$migration->addKey($table, 'entities_id');
// Version 1.3.0
$opt = array('after' => 'ip_end', 'update' => "'::1'", 'condition' => "WHERE `ip_start`=INET_ATON('127.0.0.1')");
$migration->addField($table, 'ipv6', 'string', $opt);
} else {
$sql = "CREATE TABLE `glpi_plugin_webservices_clients` (\n `id` INT NOT NULL AUTO_INCREMENT,\n `entities_id` INT NOT NULL DEFAULT '0',\n `is_recursive` TINYINT( 1 ) NOT NULL DEFAULT '0',\n `name` VARCHAR( 255 ) NOT NULL ,\n `pattern` VARCHAR( 255 ) NOT NULL ,\n `ip_start` BIGINT NULL ,\n `ip_end` BIGINT NULL ,\n `ipv6` VARCHAR( 255 ) NULL,\n `username` VARCHAR( 255 ) NULL ,\n `password` VARCHAR( 255 ) NULL ,\n `do_log` TINYINT NOT NULL DEFAULT '0',\n `debug` TINYINT NOT NULL DEFAULT '0',\n `is_active` TINYINT NOT NULL DEFAULT '0',\n `deflate` TINYINT NOT NULL DEFAULT '0',\n `comment` TEXT NULL ,\n PRIMARY KEY (`id`),\n KEY `entities_id` (`entities_id`)\n ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci ";
$DB->queryOrDie($sql, "SQL Error");
$sql = "INSERT INTO\n `glpi_plugin_webservices_clients` (`id`, `entities_id`, `is_recursive`, `name`,\n `pattern`, `ip_start`, `ip_end` , `ipv6`,\n `do_log`, `is_active`, `comment`)\n VALUES (NULL, 0, 1, '" . __('Local', 'webservices') . "',\n '.*', INET_ATON('127.0.0.1'), INET_ATON('127.0.0.1'), '::1',\n 1, 1, '" . __('Allow all from local', 'webservices') . "')";
$DB->query($sql);
}
}
示例7: install
public static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
//Install
$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_references` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_recursive` tinyint(1) NOT NULL default '0',\n `name` varchar(255) collate utf8_unicode_ci default NULL,\n `manufacturers_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_manufacturers (id)',\n `manufacturers_reference` varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT '',\n `types_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtypes tables (id)',\n `models_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemmodels tables (id)',\n `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file',\n `templates_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)',\n `comment` text collate utf8_unicode_ci,\n `is_deleted` tinyint(1) NOT NULL default '0',\n `is_active` tinyint(1) NOT NULL default '1',\n `notepad` longtext collate utf8_unicode_ci,\n `date_mod` datetime default NULL,\n PRIMARY KEY (`id`),\n KEY `name` (`name`),\n KEY `entities_id` (`entities_id`),\n KEY `manufacturers_id` (`manufacturers_id`),\n KEY `types_id` (`types_id`),\n KEY `models_id` (`models_id`),\n KEY `templates_id` (`templates_id`),\n KEY `is_active` (`is_active`),\n KEY `is_deleted` (`is_deleted`),\n KEY date_mod (date_mod)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
} else {
//Upgrade
$migration->displayMessage("Upgrading {$table}");
//1.1.0
$migration->changeField($table, "FK_manufacturer", "FK_glpi_enterprise", "int(11) NOT NULL DEFAULT '0'");
///1.2.0
$migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
$migration->changeField($table, "FK_entities", "entities_id", "int(11) NOT NULL default '0'");
$migration->changeField($table, "recursive", "is_recursive", "tinyint(1) NOT NULL default '0'");
$migration->changeField($table, "name", "name", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->changeField($table, "FK_glpi_enterprise", "manufacturers_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_manufacturers (id)'");
$migration->changeField($table, "FK_type", "types_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtypes tables (id)'");
$migration->changeField($table, "FK_model", "models_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemmodels tables (id)'");
$migration->changeField($table, "type", "itemtype", "varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file'");
$migration->changeField($table, "template", "templates_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)'");
$migration->changeField($table, "comments", "comment", "text collate utf8_unicode_ci");
$migration->changeField($table, "deleted", "is_deleted", "tinyint(1) NOT NULL default '0'");
$migration->addField($table, "notepad", "longtext collate utf8_unicode_ci");
$migration->addField($table, "is_active", "TINYINT(1) NOT NULL DEFAULT '1'");
$migration->addField($table, "date_mod", "datetime");
$migration->addKey($table, "name");
$migration->addKey($table, "entities_id");
$migration->addKey($table, "manufacturers_id");
$migration->addKey($table, "types_id");
$migration->addKey($table, "models_id");
$migration->addKey($table, "templates_id");
$migration->addKey($table, "is_deleted");
$migration->addKey($table, "is_active");
$migration->addKey($table, "date_mod");
$migration->migrationOneTable($table);
Plugin::migrateItemType(array(3151 => 'PluginOrderReference'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs"));
if (FieldExists('glpi_tickets', 'itemtype')) {
Plugin::migrateItemType(array(3151 => 'PluginOrderReference'), array("glpi_tickets"));
}
Plugin::migrateItemType(array(), array(), array($table));
//1.3.0
$DB->query("UPDATE `glpi_plugin_order_references` SET\n `itemtype`='ConsumableItem'\n WHERE `itemtype` ='Consumable'") or die($DB->error());
$DB->query("UPDATE `glpi_plugin_order_references` SET\n `itemtype`='CartridgeItem'\n WHERE `itemtype` ='Cartridge'") or die($DB->error());
//1.7.0
$migration->addField($table, "date_mod", "DATETIME NULL");
$migration->addKey($table, "date_mod");
//Displayprefs
$prefs = array(1 => 1, 2 => 4, 4 => 5, 5 => 9, 6 => 6, 7 => 7);
foreach ($prefs as $num => $rank) {
if (!countElementsInTable("glpi_displaypreferences", "`itemtype`='PluginOrderReference' AND `num`='{$num}'\n AND `users_id`='0'")) {
$DB->query("INSERT INTO glpi_displaypreferences\n VALUES (NULL,'PluginOrderReference','{$num}','{$rank}','0');");
}
}
//Fix error naming field
if (FieldExists($table, 'manufacturer_reference')) {
$migration->changeField($table, "manufacturer_reference", "manufacturers_reference", "varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT ''");
$migration->migrationOneTable($table);
}
//2.0.1
if (!FieldExists($table, 'manufacturers_reference')) {
$migration->addField($table, "manufacturers_reference", "varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT ''");
$migration->migrationOneTable($table);
}
}
}
示例8: plugin_archires_updateTo180
function plugin_archires_updateTo180()
{
$migration = new Migration(180);
$migration->renameTable("glpi_plugin_archires_query_location", "glpi_plugin_archires_locationqueries");
$migration->renameTable("glpi_plugin_archires_query_switch", "glpi_plugin_archires_networkequipmentqueries");
$migration->renameTable("glpi_plugin_archires_query_applicatifs", "glpi_plugin_archires_appliancequeries");
$migration->renameTable("glpi_plugin_archires_image_device", "glpi_plugin_archires_imageitems");
$migration->renameTable("glpi_plugin_archires_query_type", "glpi_plugin_archires_querytypes");
$migration->renameTable("glpi_plugin_archires_color_iface", "glpi_plugin_archires_networkinterfacecolors");
$migration->renameTable("glpi_plugin_archires_color_state", "glpi_plugin_archires_statecolors");
$migration->renameTable("glpi_plugin_archires_color_vlan", "glpi_plugin_archires_vlancolors");
$migration->renameTable("glpi_plugin_archires_config", "glpi_plugin_archires_views");
$migration->dropKey("glpi_plugin_archires_locationqueries", "deleted");
$migration->changeField("glpi_plugin_archires_locationqueries", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_archires_locationqueries", "name", "name", 'string');
$migration->changeField("glpi_plugin_archires_locationqueries", "FK_entities", "entities_id", 'integer');
$migration->changeField("glpi_plugin_archires_locationqueries", "location", "locations_id", 'integer', array('comment' => 'RELATION to glpi_locations (id)'));
$migration->changeField("glpi_plugin_archires_locationqueries", "network", "networks_id", 'integer', array('comment' => 'RELATION to glpi_networks (id)'));
$migration->changeField("glpi_plugin_archires_locationqueries", "state", "states_id", 'integer', array('comment' => 'RELATION to glpi_states (id)'));
$migration->changeField("glpi_plugin_archires_locationqueries", "FK_group", "groups_id", 'integer', array('comment' => 'RELATION to glpi_groups (id)'));
$migration->changeField("glpi_plugin_archires_locationqueries", "FK_config", "plugin_archires_views_id", 'integer', array('comment' => 'RELATION to glpi_plugin_archires_views (id)'));
$migration->changeField("glpi_plugin_archires_locationqueries", "FK_vlan", "vlans_id", 'integer', array('comment' => 'RELATION to glpi_vlans (id)'));
$migration->changeField("glpi_plugin_archires_locationqueries", "deleted", "is_deleted", 'bool');
$migration->changeField("glpi_plugin_archires_locationqueries", "notes", "notepad", 'longtext');
$migration->dropField("glpi_plugin_archires_locationqueries", "link");
$migration->addKey("glpi_plugin_archires_locationqueries", "name");
$migration->addKey("glpi_plugin_archires_locationqueries", "entities_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "locations_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "networks_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "groups_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "plugin_archires_views_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "states_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "vlans_id");
$migration->addKey("glpi_plugin_archires_locationqueries", "is_deleted");
$migration->dropKey("glpi_plugin_archires_networkequipmentqueries", "deleted");
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "name", "name", 'string');
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "FK_entities", "entities_id", 'integer');
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "switch", "networkequipments_id", 'integer', array('comment' => 'RELATION to glpi_networkequipments (id)'));
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "network", "networks_id", 'integer', array('comment' => 'RELATION to glpi_networks (id)'));
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "state", "states_id", 'integer', array('comment' => 'RELATION to glpi_states (id)'));
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "FK_group", "groups_id", 'integer', array('comment' => 'RELATION to glpi_groups (id)'));
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "FK_config", "plugin_archires_views_id", 'integer', array('comment' => 'RELATION to glpi_plugin_archires_views (id)'));
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "FK_vlan", "vlans_id", 'integer', array('comment' => 'RELATION to glpi_vlans (id)'));
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "deleted", "is_deleted", 'bool');
$migration->changeField("glpi_plugin_archires_networkequipmentqueries", "notes", "notepad", 'longtext');
$migration->dropField("glpi_plugin_archires_networkequipmentqueries", "link");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "name");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "entities_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "networkequipments_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "networks_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "groups_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "plugin_archires_views_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "states_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "vlans_id");
$migration->addKey("glpi_plugin_archires_networkequipmentqueries", "is_deleted");
$migration->dropKey("glpi_plugin_archires_appliancequeries", "deleted");
$migration->changeField("glpi_plugin_archires_appliancequeries", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_archires_appliancequeries", "name", "name", 'string');
$migration->changeField("glpi_plugin_archires_appliancequeries", "FK_entities", "entities_id", 'integer');
$migration->changeField("glpi_plugin_archires_appliancequeries", "applicatifs", "appliances_id", 'integer', array('comment' => 'RELATION to glpi_plugin_appliances (id)'));
$migration->changeField("glpi_plugin_archires_appliancequeries", "network", "networks_id", 'integer', array('comment' => 'RELATION to glpi_networks (id)'));
$migration->changeField("glpi_plugin_archires_appliancequeries", "state", "states_id", 'integer', array('comment' => 'RELATION to glpi_states (id)'));
$migration->changeField("glpi_plugin_archires_appliancequeries", "FK_group", "groups_id", 'integer', array('comment' => 'RELATION to glpi_groups (id)'));
$migration->changeField("glpi_plugin_archires_appliancequeries", "FK_config", "plugin_archires_views_id", 'integer', array('comment' => 'RELATION to glpi_plugin_archires_views (id)'));
$migration->changeField("glpi_plugin_archires_appliancequeries", "FK_vlan", "vlans_id", 'integer', array('comment' => 'RELATION to glpi_vlans (id)'));
$migration->changeField("glpi_plugin_archires_appliancequeries", "deleted", "is_deleted", 'bool');
$migration->changeField("glpi_plugin_archires_appliancequeries", "notes", "notepad", 'longtext');
$migration->dropField("glpi_plugin_archires_appliancequeries", "link");
$migration->addKey("glpi_plugin_archires_appliancequeries", "name");
$migration->addKey("glpi_plugin_archires_appliancequeries", "entities_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "appliances_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "networks_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "groups_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "plugin_archires_views_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "states_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "vlans_id");
$migration->addKey("glpi_plugin_archires_appliancequeries", "is_deleted");
$migration->dropKey("glpi_plugin_archires_imageitems", "device_type");
$migration->changeField("glpi_plugin_archires_imageitems", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_archires_imageitems", "type", "type", 'integer');
$migration->changeField("glpi_plugin_archires_imageitems", "device_type", "itemtype", "varchar(100) collate utf8_unicode_ci NOT NULL", array('comment' => 'see .class.php file'));
$migration->dropKey("glpi_plugin_archires_querytypes", "FK_query");
$migration->dropKey("glpi_plugin_archires_querytypes", "type");
$migration->dropKey("glpi_plugin_archires_querytypes", "type_query");
$migration->dropKey("glpi_plugin_archires_querytypes", "device_type");
$migration->changeField("glpi_plugin_archires_querytypes", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_archires_querytypes", "type_query", "querytype", "varchar(100) collate utf8_unicode_ci NOT NULL", array('comment' => 'RELATION to the 3 type of archires (type)'));
$migration->changeField("glpi_plugin_archires_querytypes", "type", "type", 'integer');
$migration->changeField("glpi_plugin_archires_querytypes", "device_type", "itemtype", "varchar(100) collate utf8_unicode_ci NOT NULL", array('comment' => 'see .class.php file'));
$migration->changeField("glpi_plugin_archires_querytypes", "FK_query", "plugin_archires_queries_id", 'integer', array('comment' => 'RELATION to the 3 queries tables (id)'));
$migration->addKey("glpi_plugin_archires_querytypes", "querytype");
$migration->addKey("glpi_plugin_archires_querytypes", "type");
$migration->addKey("glpi_plugin_archires_querytypes", "itemtype");
$migration->addKey("glpi_plugin_archires_querytypes", "plugin_archires_queries_id");
$migration->migrationOneTable("glpi_plugin_archires_querytypes");
$query = "UPDATE `glpi_plugin_archires_querytypes`\n SET `querytype` = 'PluginArchiresLocationQuery'\n WHERE `querytype` = 0";
$DB->queryOrDie($query, __('1.8.0 update glpi_plugin_archires_querytypes (querytype) ', 'archires') . $DB->error());
$query = "UPDATE `glpi_plugin_archires_querytypes`\n SET `querytype` = 'PluginArchiresNetworkEquipmentQuery'\n WHERE `querytype` = 1";
$DB->queryOrDie($query, __('1.8.0 update glpi_plugin_archires_querytypes (querytype) ', 'archires') . $DB->error());
//.........这里部分代码省略.........
示例9: plugin_ocsinventoryng_upgrademassocsimport13to14
function plugin_ocsinventoryng_upgrademassocsimport13to14()
{
global $DB;
$migration = new Migration(14);
$migration->renameTable("glpi_plugin_massocsimport", "glpi_plugin_massocsimport_threads");
$migration->changeField("glpi_plugin_massocsimport_threads", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_massocsimport_threads", "thread_id", "threadid", 'integer');
$migration->changeField("glpi_plugin_massocsimport_threads", "status", "status", 'integer');
$migration->changeField("glpi_plugin_massocsimport_threads", "ocs_server_id", "ocsservers_id", 'integer', array('value' => 1));
$migration->changeField("glpi_plugin_massocsimport_threads", "process_id", "processid", 'integer');
$migration->changeField("glpi_plugin_massocsimport_threads", "noupdate_machines_number", "notupdated_machines_number", 'integer');
$migration->migrationOneTable("glpi_plugin_massocsimport_threads");
$migration->addKey("glpi_plugin_massocsimport_threads", array("processid", "threadid"), "process_thread");
$migration->renameTable("glpi_plugin_massocsimport_config", "glpi_plugin_massocsimport_configs");
$migration->dropField("glpi_plugin_massocsimport_configs", "delete_frequency");
$migration->dropField("glpi_plugin_massocsimport_configs", "enable_logging");
$migration->dropField("glpi_plugin_massocsimport_configs", "delete_empty_frequency");
$migration->dropField("glpi_plugin_massocsimport_configs", "warn_if_not_imported");
$migration->dropField("glpi_plugin_massocsimport_configs", "not_imported_threshold");
$migration->changeField("glpi_plugin_massocsimport_configs", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_massocsimport_configs", "thread_log_frequency", "thread_log_frequency", 'integer', array('value' => 10));
$migration->changeField("glpi_plugin_massocsimport_configs", "display_empty", "is_displayempty", 'int(1) NOT NULL default 1');
$migration->changeField("glpi_plugin_massocsimport_configs", "default_ocs_server", "ocsservers_id", 'integer', array('value' => -1));
$migration->changeField("glpi_plugin_massocsimport_configs", "delay_refresh", "delay_refresh", 'integer');
$migration->changeField("glpi_plugin_massocsimport_configs", "comments", "comment", 'text');
$migration->changeField("glpi_plugin_massocsimport_details", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_massocsimport_details", "process_id", "plugin_massocsimport_threads_id", 'integer');
$migration->changeField("glpi_plugin_massocsimport_details", "thread_id", "threadid", 'integer');
$migration->changeField("glpi_plugin_massocsimport_details", "ocs_id", "ocsid", 'integer');
$migration->changeField("glpi_plugin_massocsimport_details", "glpi_id", "computers_id", 'integer');
$migration->changeField("glpi_plugin_massocsimport_details", "ocs_server_id", "ocsservers_id", 'integer', array('value' => 1));
$migration->migrationOneTable('glpi_plugin_massocsimport_details');
$migration->addKey("glpi_plugin_massocsimport_details", array("plugin_massocsimport_threads_id", "threadid"), "process_thread");
$migration->renameTable("glpi_plugin_massocsimport_not_imported", "glpi_plugin_massocsimport_notimported");
$migration->changeField("glpi_plugin_massocsimport_notimported", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_massocsimport_notimported", "ocs_id", "ocsid", 'integer');
$migration->changeField("glpi_plugin_massocsimport_notimported", "ocs_server_id", "ocsservers_id", 'integer');
$migration->changeField("glpi_plugin_massocsimport_notimported", "deviceid", "ocs_deviceid", 'string');
$migration->changeField("glpi_plugin_massocsimport_servers", "ID", "id", 'autoincrement');
$migration->changeField("glpi_plugin_massocsimport_servers", "ocs_server_id", "ocsservers_id", 'integer');
$migration->changeField("glpi_plugin_massocsimport_servers", "max_ocs_id", "max_ocsid", 'int(11) DEFAULT NULL');
$migration->changeField("glpi_plugin_massocsimport_servers", "max_glpi_date", "max_glpidate", 'datetime DEFAULT NULL');
$migration->executeMigration();
}
示例10: install
public static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table) && !TableExists("glpi_plugin_order_detail")) {
$migration->displayMessage("Installing {$table}");
//install
$query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_recursive` tinyint(1) NOT NULL default '0',\n `plugin_order_orders_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orders (id)',\n `itemtype` varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file',\n `items_id` int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)',\n `plugin_order_references_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_references (id)',\n `plugin_order_deliverystates_id` int (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_deliverystates (id)',\n `plugin_order_ordertaxes_id` float NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_ordertaxes (id)',\n `delivery_number` varchar(255) collate utf8_unicode_ci default NULL,\n `delivery_comment` text collate utf8_unicode_ci,\n `price_taxfree` decimal(20,6) NOT NULL DEFAULT '0.000000',\n `price_discounted` decimal(20,6) NOT NULL DEFAULT '0.000000',\n `discount` decimal(20,6) NOT NULL DEFAULT '0.000000',\n `price_ati` decimal(20,6) NOT NULL DEFAULT '0.000000',\n `states_id` int(11) NOT NULL default 1,\n `delivery_date` date default NULL,\n `plugin_order_bills_id` INT( 11 ) NOT NULL DEFAULT '0',\n `plugin_order_billstates_id` INT( 11 ) NOT NULL DEFAULT '0',\n `comment` text collate utf8_unicode_ci,\n PRIMARY KEY (`id`),\n KEY `FK_device` (`items_id`,`itemtype`),\n KEY `entities_id` (`entities_id`),\n KEY `item` (`itemtype`,`items_id`),\n KEY `plugin_order_references_id` (`plugin_order_references_id`),\n KEY `plugin_order_deliverystates_id` (`plugin_order_deliverystates_id`),\n KEY `states_id` (`states_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
} else {
//Upgrade
$migration->displayMessage("Upgrading {$table}");
//1.1.2
if (TableExists("glpi_plugin_order_detail")) {
$migration->addField("glpi_plugin_order_detail", "delivery_status", "int(1) NOT NULL default '0'");
$migration->addField("glpi_plugin_order_detail", "delivery_comments", "TEXT");
$migration->migrationOneTable("glpi_plugin_order_detail");
}
//1.2.0
$migration->renameTable("glpi_plugin_order_detail", $table);
$migration->changeField($table, "ID", "id", "int(11) NOT NULL AUTO_INCREMENT");
$migration->changeField($table, "FK_order", "plugin_order_orders_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orders (id)'");
$migration->changeField($table, "device_type", "itemtype", "varchar(100) collate utf8_unicode_ci NOT NULL COMMENT 'see .class.php file'");
$migration->changeField($table, "FK_device", "items_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to various tables, according to itemtype (id)'");
$migration->changeField($table, "FK_reference", "plugin_order_references_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_references (id)'");
$migration->changeField($table, "delivery_status", "plugin_order_deliverystates_id", "int (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_deliverystates (id)'");
$migration->changeField($table, "deliverynum", "delivery_number", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->changeField($table, "delivery_comments", "delivery_comment", "text collate utf8_unicode_ci");
$migration->changeField($table, "status", "states_id", "int(11) NOT NULL default 1");
$migration->changeField($table, "date", "delivery_date", "date default NULL");
$migration->addKey($table, array("items_id", "itemtype"), "FK_device");
$migration->addKey($table, array("itemtype", "items_id"), "item");
$migration->addKey($table, "plugin_order_references_id");
$migration->addKey($table, "plugin_order_deliverystates_id");
$migration->addKey($table, "states_id");
$migration->migrationOneTable($table);
Plugin::migrateItemType(array(), array(), array($table));
//1.4.0
$migration->addField($table, "plugin_order_ordertaxes_id", "INT (11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_ordertaxes (id)'");
$migration->migrationOneTable($table);
/* Migrate VAT */
foreach ($DB->request("glpi_plugin_order_orders") as $data) {
$query = "UPDATE `glpi_plugin_order_orders_items`\n SET `plugin_order_ordertaxes_id` = '" . $data["plugin_order_ordertaxes_id"] . "'\n WHERE `plugin_order_orders_id` = '" . $data["id"] . "'";
$result = $DB->query($query) or die($DB->error());
}
//1.5.0
$migration->addField($table, "entities_id", "INT( 11 ) NOT NULL DEFAULT '0'");
$migration->addField($table, "is_recursive", "TINYINT( 1 ) NOT NULL DEFAULT '0'");
$migration->addField($table, "plugin_order_bills_id", "INT( 11 ) NOT NULL DEFAULT '0'");
$migration->addField($table, "plugin_order_billstates_id", "INT( 11 ) NOT NULL DEFAULT '0'");
$migration->addKey($table, "entities_id");
$migration->addKey($table, "plugin_order_bills_id");
$migration->addKey($table, "plugin_order_billstates_id");
$migration->addField($table, "comment", "text collate utf8_unicode_ci");
$migration->migrationOneTable($table);
//Change format for prices : from float to decimal
$migration->changeField($table, "price_taxfree", "price_taxfree", "decimal(20,6) NOT NULL DEFAULT '0.000000'");
$migration->changeField($table, "price_discounted", "price_discounted", "decimal(20,6) NOT NULL DEFAULT '0.000000'");
$migration->changeField($table, "price_ati", "price_ati", "decimal(20,6) NOT NULL DEFAULT '0.000000'");
$migration->changeField($table, "discount", "discount", "decimal(20,6) NOT NULL DEFAULT '0.000000'");
//Drop unused fields from previous migration
$migration->dropField($table, "price_taxfree2");
$migration->dropField($table, "price_discounted2");
$migration->migrationOneTable($table);
//Forward entities_id and is_recursive into table glpi_plugin_order_orders_items
$query = "SELECT `go`.`entities_id` as entities_id ,\n `go`.`is_recursive` as is_recursive, `goi`.`id` as items_id\n FROM `glpi_plugin_order_orders` as go, `{$table}` as `goi`\n WHERE `goi`.`plugin_order_orders_id`=`go`.`id`";
foreach ($DB->request($query) as $data) {
$update = "UPDATE `{$table}`\n SET `entities_id`='" . $data['entities_id'] . "'\n AND `is_recursive`='" . $data['is_recursive'] . "'\n WHERE `id`='" . $data['items_id'] . "'";
$DB->query($update) or die($DB->error());
}
$migration->executeMigration();
}
}
示例11: install
static function install(Migration $migration)
{
global $DB;
//Only avaiable since 1.2.0
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE `glpi_plugin_order_preferences` (\n `id` int(11) NOT NULL auto_increment,\n `users_id` int(11) NOT NULL default 0,\n `template` varchar(255) collate utf8_unicode_ci default NULL,\n `sign` varchar(255) collate utf8_unicode_ci default NULL,\n PRIMARY KEY (`id`),\n KEY `users_id` (`users_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
} else {
//1.5.3
$migration->changeField($table, 'ID', 'id', "int(11) NOT NULL auto_increment");
$migration->changeField($table, 'user_id', 'users_id', "INT(11) NOT NULL DEFAULT '0'");
$migration->addKey($table, 'users_id');
$migration->migrationOneTable($table);
}
}
示例12: install
public static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table) && !TableExists("glpi_plugin_order_references_manufacturers")) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_references_suppliers` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_recursive` tinyint(1) NOT NULL default '0',\n `plugin_order_references_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_references (id)',\n `suppliers_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)',\n `price_taxfree` decimal(20,4) NOT NULL DEFAULT '0.0000',\n `reference_code` varchar(255) collate utf8_unicode_ci default NULL,\n PRIMARY KEY (`id`),\n KEY `entities_id` (`entities_id`),\n KEY `plugin_order_references_id` (`plugin_order_references_id`),\n KEY `suppliers_id` (`suppliers_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
} else {
$migration->displayMessage("Upgrading {$table}");
//1.1.0
if (TableExists("glpi_plugin_order_references_manufacturers")) {
$migration->addField("glpi_plugin_order_references_manufacturers", "reference_code", "varchar(255) NOT NULL collate utf8_unicode_ci default ''");
$migration->migrationOneTable("glpi_plugin_order_references_manufacturers");
}
//1.2.0
$migration->renameTable("glpi_plugin_order_references_manufacturers", $table);
$migration->addField($table, "is_recursive", "int(11) NOT NULL default '0'");
$migration->addKey($table, "suppliers_id");
$migration->addKey($table, "plugin_order_references_id");
$migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
$migration->changeField($table, "FK_entities", "entities_id", "int(11) NOT NULL default '0'");
$migration->changeField($table, "FK_reference", "plugin_order_references_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_references (id)'");
$migration->changeField($table, "FK_enterprise", "suppliers_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)'");
$migration->changeField($table, "reference_code", "reference_code", "varchar(255) collate utf8_unicode_ci default NULL");
$migration->changeField($table, "price_taxfree", "price_taxfree", "decimal(20,4) NOT NULL DEFAULT '0.0000'");
$migration->migrationOneTable($table);
Plugin::migrateItemType(array(3152 => 'PluginOrderReference_Supplier'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs"), array());
if (FieldExists('glpi_tickets', 'itemtype')) {
Plugin::migrateItemType(array(3152 => 'PluginOrderReference_Supplier'), array("glpi_tickets"), array());
}
//1.5.0
$query = "SELECT `entities_id`,`is_recursive`,`id` FROM `glpi_plugin_order_references` ";
foreach ($DB->request($query) as $data) {
$query = "UPDATE `glpi_plugin_order_references_suppliers`\n SET `entities_id` = '" . $data["entities_id"] . "',`is_recursive` = '" . $data["is_recursive"] . "'\n WHERE `plugin_order_references_id` = '" . $data["id"] . "' ";
$DB->query($query) or die($DB->error());
}
}
}
示例13: install
static function install(Migration $migration)
{
global $DB;
$table = getTableForItemType(__CLASS__);
if (!TableExists($table)) {
$migration->displayMessage("Installing {$table}");
$query = "CREATE TABLE `glpi_plugin_order_profiles` (\n `id` int(11) NOT NULL auto_increment,\n `profiles_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',\n `order` char(1) collate utf8_unicode_ci default NULL,\n `reference` char(1) collate utf8_unicode_ci default NULL,\n `validation` char(1) collate utf8_unicode_ci default NULL,\n `cancel` char(1) collate utf8_unicode_ci default NULL,\n `undo_validation` char(1) collate utf8_unicode_ci default NULL,\n `bill` char(1) collate utf8_unicode_ci default NULL,\n `delivery` char(1) collate utf8_unicode_ci default NULL,\n `generate_order_odt` char(1) collate utf8_unicode_ci default NULL,\n `open_ticket` char(1) default NULL,\n PRIMARY KEY (`id`),\n KEY `profiles_id` (`profiles_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
PluginOrderProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
} else {
$migration->displayMessage("Upgrading {$table}");
//1.2.0
$migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
foreach (array('order', 'reference', 'budget', 'validation', 'cancel', 'undo_validation') as $right) {
$migration->changeField($table, $right, $right, "char(1) collate utf8_unicode_ci default NULL");
}
$migration->migrationOneTable($table);
if ($migration->addField($table, "profiles_id", "int(11) NOT NULL default '0'")) {
$migration->addKey($table, "profiles_id");
$migration->migrationOneTable($table);
//Migration profiles
$DB->query("UPDATE `{$table}` SET `profiles_id`=`id`");
}
//1.4.0
$migration->dropField($table, "budget");
$migration->dropField($table, "name");
$migration->migrationOneTable($table);
//1.5.0
$migration->addField($table, "bill", "char");
$migration->migrationOneTable($table);
self::addRightToProfile($_SESSION['glpiactiveprofile']['id'], "bill", "w");
//1.5.3
//Add delivery right
if ($migration->addField($table, "delivery", "char")) {
$migration->migrationOneTable($table);
//Update profiles : copy order right not to change current behavior
$update = "UPDATE `{$table}` SET `delivery`=`order`";
$DB->query($update);
self::addRightToProfile($_SESSION['glpiactiveprofile']['id'], "delivery", "w");
}
if ($migration->addField($table, "generate_order_odt", "char")) {
$migration->migrationOneTable($table);
//Update profiles : copy order right not to change current behavior
$update = "UPDATE `{$table}` SET `generate_order_odt`=`order`";
$DB->query($update);
self::addRightToProfile($_SESSION['glpiactiveprofile']['id'], "generate_order_odt", "w");
}
}
//1.7.2
$migration->addField($table, "open_ticket", "char");
$migration->migrationOneTable($table);
self::addRightToProfile($_SESSION['glpiactiveprofile']['id'], "open_ticket", "w");
self::changeProfile();
}
示例14: install
public static function install(Migration $migration)
{
global $DB;
//Only avaiable since 1.3.0
$table = getTableForItemType(__CLASS__);
if (!TableExists("glpi_plugin_order_surveysuppliers")) {
$migration->displayMessage("Installing {$table}");
//Installation
$query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_surveysuppliers` (\n `id` int(11) NOT NULL auto_increment,\n `entities_id` int(11) NOT NULL default '0',\n `is_recursive` tinyint(1) NOT NULL default '0',\n `plugin_order_orders_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orders (id)',\n `suppliers_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)',\n `answer1` int(11) NOT NULL default 0,\n `answer2` int(11) NOT NULL default 0,\n `answer3` int(11) NOT NULL default 0,\n `answer4` int(11) NOT NULL default 0,\n `answer5` int(11) NOT NULL default 0,\n `comment` text collate utf8_unicode_ci,\n PRIMARY KEY (`id`),\n KEY `plugin_order_orders_id` (`plugin_order_orders_id`),\n KEY `entities_id` (`entities_id`),\n KEY `suppliers_id` (`suppliers_id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
} else {
//upgrade
$migration->displayMessage("Upgrading {$table}");
//1.2.0
$migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
$migration->changeField($table, "FK_order", "plugin_order_orders_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orders (id)'");
$migration->changeField($table, "FK_enterprise", "suppliers_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)'");
$migration->changeField($table, "comment", "comment", "text collate utf8_unicode_ci");
$migration->addField($table, "entities_id", "int(11) NOT NULL default '0'");
$migration->addField($table, "is_recursive", "tinyint(1) NOT NULL default '0'");
$migration->addKey($table, "plugin_order_orders_id");
$migration->addKey($table, "suppliers_id");
$migration->migrationOneTable($table);
$query = "SELECT `suppliers_id`, `entities_id`,`is_recursive`,`id`\n FROM `glpi_plugin_order_orders` ";
foreach ($DB->request($query) as $data) {
$query = "UPDATE `glpi_plugin_order_surveysuppliers` SET\n `entities_id` = '{$data["entities_id"]}',\n `is_recursive` = '{$data["is_recursive"]}'\n WHERE `plugin_order_orders_id` = '{$data["id"]}' ";
$DB->query($query) or die($DB->error());
}
}
}
示例15: plugin_escalade_install
function plugin_escalade_install()
{
global $DB;
//get version
$plugin = new Plugin();
$found = $plugin->find("name = 'escalade'");
$plugin_escalade = array_shift($found);
//init migration
$migration = new Migration($plugin_escalade['version']);
// == Tables creation (initial installation) ==
if (!TableExists('glpi_plugin_escalade_histories')) {
$query = "CREATE TABLE `glpi_plugin_escalade_histories` (\n `id` INT(11) NOT NULL AUTO_INCREMENT,\n `tickets_id` INT(11) NOT NULL,\n `groups_id` INT(11) NOT NULL,\n `date_mod` DATETIME NOT NULL,\n PRIMARY KEY (`id`),\n KEY `tickets_id` (`tickets_id`),\n KEY `groups_id` (`groups_id`)\n ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query);
}
if (!TableExists('glpi_plugin_escalade_configs')) {
$query = "CREATE TABLE `glpi_plugin_escalade_configs` (\n `id` INT(11) NOT NULL AUTO_INCREMENT,\n `remove_group` INT(11) NOT NULL,\n `remove_delete_group_btn` INT(11) NOT NULL,\n `remove_delete_user_btn` INT(11) NOT NULL,\n `show_history` INT(11) NOT NULL,\n `task_history` INT(11) NOT NULL,\n `remove_tech` INT(11) NOT NULL,\n `solve_return_group` INT(11) NOT NULL,\n `reassign_group_from_cat` INT(11) NOT NULL,\n `reassign_tech_from_cat` INT(11) NOT NULL,\n `cloneandlink_ticket` INT(11) NOT NULL,\n `close_linkedtickets` INT(11) NOT NULL,\n `use_assign_user_group` INT(11) NOT NULL,\n `use_assign_user_group_creation` INT(11) NOT NULL,\n `use_assign_user_group_modification` INT(11) NOT NULL,\n `assign_me_ticket` INT(11) NOT NULL,\n `use_filter_assign_group` INT(11) NOT NULL,\n `ticket_last_status` INT(11) NOT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query);
$query = "INSERT INTO glpi_plugin_escalade_configs \n VALUES (NULL, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, '" . Ticket::WAITING . "')";
$DB->query($query);
}
// == Update to 1.2 ==
if (!FieldExists('glpi_plugin_escalade_configs', 'cloneandlink_ticket')) {
$migration->addField('glpi_plugin_escalade_configs', 'cloneandlink_ticket', 'INT(11) NOT NULL', array('after' => 'reassign_tech_from_cat'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'close_linkedtickets')) {
$migration->addField('glpi_plugin_escalade_configs', 'close_linkedtickets', 'INT(11) NOT NULL', array('after' => 'cloneandlink_ticket'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'use_assign_user_group')) {
$migration->addField('glpi_plugin_escalade_configs', 'use_assign_user_group', 'INT(11) NOT NULL', array('after' => 'close_linkedtickets'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'use_assign_user_group_creation')) {
$migration->addField('glpi_plugin_escalade_configs', 'use_assign_user_group_creation', 'INT(11) NOT NULL', array('after' => 'use_assign_user_group'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'use_assign_user_group_modification')) {
$migration->addField('glpi_plugin_escalade_configs', 'use_assign_user_group_modification', 'INT(11) NOT NULL', array('after' => 'use_assign_user_group_creation'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'remove_delete_group_btn')) {
$migration->addField('glpi_plugin_escalade_configs', 'remove_delete_group_btn', 'INT(11) NOT NULL', array('after' => 'remove_group'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'assign_me_ticket')) {
$migration->addField('glpi_plugin_escalade_configs', 'assign_me_ticket', 'INT(11) NOT NULL', array('after' => 'use_assign_user_group_modification'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!isIndex("glpi_plugin_escalade_histories", 'tickets_id') || !isIndex("glpi_plugin_escalade_histories", 'groups_id')) {
$migration->addKey("glpi_plugin_escalade_histories", 'tickets_id', 'tickets_id');
$migration->addKey("glpi_plugin_escalade_histories", 'groups_id', 'groups_id');
$migration->migrationOneTable('glpi_plugin_escalade_histories');
}
// == Update to 1.3 ==
if (!FieldExists('glpi_plugin_escalade_configs', 'remove_delete_user_btn')) {
$migration->addField('glpi_plugin_escalade_configs', 'remove_delete_user_btn', 'INT(11) NOT NULL DEFAULT 1', array('after' => 'remove_delete_group_btn'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!FieldExists('glpi_plugin_escalade_configs', 'use_filter_assign_group')) {
$migration->addField('glpi_plugin_escalade_configs', 'use_filter_assign_group', 'INT(11) NOT NULL', array('after' => 'use_assign_user_group_modification'));
$migration->migrationOneTable('glpi_plugin_escalade_configs');
}
if (!TableExists('glpi_plugin_escalade_groups_groups')) {
$query = "CREATE TABLE `glpi_plugin_escalade_groups_groups` (\n `id` INT(11) NOT NULL AUTO_INCREMENT,\n `groups_id_source` int(11) NOT NULL DEFAULT '0',\n `groups_id_destination` int(11) NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`)\n ) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query);
}
// Update for 0.84 status
if (TableExists('glpi_plugin_escalade_configs')) {
foreach ($DB->request("glpi_plugin_escalade_configs") as $data) {
switch ($data['ticket_last_status']) {
case 'solved':
$status = Ticket::SOLVED;
break;
case 'waiting':
$status = Ticket::WAITING;
break;
case 'closed':
$status = Ticket::CLOSED;
break;
case 'assign':
$status = Ticket::ASSIGNED;
break;
case 'new':
$status = Ticket::INCOMING;
break;
case 'plan':
$status = Ticket::PLANNED;
break;
default:
$status = -1;
break;
}
$query = "UPDATE `glpi_plugin_escalade_configs`\n SET `ticket_last_status` = '" . $status . "'\n WHERE `id` = '" . $data['id'] . "'";
$DB->query($query);
}
$query = "ALTER TABLE `glpi_plugin_escalade_configs` MODIFY `ticket_last_status` INT(11);";
$DB->query($query);
}
return true;
//.........这里部分代码省略.........