当前位置: 首页>>代码示例>>PHP>>正文


PHP Migration::executeMigration方法代码示例

本文整理汇总了PHP中Migration::executeMigration方法的典型用法代码示例。如果您正苦于以下问题:PHP Migration::executeMigration方法的具体用法?PHP Migration::executeMigration怎么用?PHP Migration::executeMigration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Migration的用法示例。


在下文中一共展示了Migration::executeMigration方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: plugin_vip_install

function plugin_vip_install()
{
    global $DB;
    $migration = new Migration(100);
    // Création de la table uniquement lors de la première installation
    if (!TableExists("glpi_plugin_vip_profiles")) {
        // Table des droits du profil
        $query = "CREATE TABLE `glpi_plugin_vip_profiles` (\n\t               `id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',\n\t               `show_vip_tab` tinyint(1) collate utf8_unicode_ci default NULL,\n\t               PRIMARY KEY  (`id`)\n\t             ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die("Error creating Vip Profiles table" . $DB->error());
        $migration->executeMigration();
        //creation du premier accès nécessaire lors de l'installation du plugin
        include_once GLPI_ROOT . "/plugins/vip/inc/profile.class.php";
        PluginVipProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']);
    }
    if (!TableExists("glpi_plugin_vip_groups")) {
        //
        $query = "CREATE TABLE `glpi_plugin_vip_groups` (\n                  `id` int(11) NOT NULL default 0 COMMENT 'RELATION to glpi_groups(id)',\n                  `isvip` tinyint(1) default '0',\n                  PRIMARY KEY (`id`)\n                ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die("Erreur lors de la création de la table des groupes vip " . $DB->error());
        $query = "INSERT INTO `glpi_plugin_vip_groups`\n                  (`id`, `isvip`)\n                  VALUES ('0', '0')";
        $DB->query($query) or die("Erreur lors de l'insertion des valeurs par défaut dans la table des groupes vip " . $DB->error());
    }
    if (!TableExists("glpi_plugin_vip_tickets")) {
        $query = "CREATE TABLE glpi_plugin_vip_tickets (\n\t\t\t\t  id int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_tickets (id)',\n\t\t\t\t  isvip tinyint(1) default '0',\n\t\t\t\t  PRIMARY KEY (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die("Error creating Vip Tickets table");
    }
    $query = "INSERT INTO glpi_plugin_vip_tickets\n\t\t\t\t   SELECT id, '0'\n\t\t\t\t\t FROM glpi_tickets\n\t\t ON DUPLICATE KEY\n\t\t\t\t   UPDATE isvip = '0'";
    $DB->query($query) or die("Error inserting ticket in Vip Tickets table");
    $migration->executeMigration();
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:30,代码来源:hook.php

示例2: install

/**
 * Install
 *
 * @return bool for success (will die for most error)
 * */
function install()
{
    global $DB;
    $migration = new Migration(100);
    // Install script
    $DB->runFile(GLPI_ROOT . "/plugins/consumables/install/sql/empty-1.0.0.sql");
    // Notification
    // Request
    $query_id = "INSERT INTO `glpi_notificationtemplates`(`name`, `itemtype`, `date_mod`, `comment`, `css`) VALUES ('Consumables Request','PluginConsumablesRequest', NOW(),'','');";
    $result = $DB->query($query_id) or die($DB->error());
    $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginConsumablesRequest' AND `name` = 'Consumables Request'";
    $result = $DB->query($query_id) or die($DB->error());
    $itemtype = $DB->result($result, 0, 'id');
    $query = "INSERT INTO `glpi_notificationtemplatetranslations`\r\nVALUES(NULL, '" . $itemtype . "', '','##consumable.action## : ##consumable.entity##',\r\n'##lang.consumable.entity## :##consumable.entity##\r\n##lang.consumablerequest.requester## : ##consumablerequest.requester##\t\r\n##lang.consumablerequest.consumabletype## : ##consumablerequest.consumabletype##\t\r\n##lang.consumablerequest.consumable## : ##consumablerequest.consumable##\r\n##lang.consumablerequest.number## : ##consumablerequest.number##\r\n##lang.consumablerequest.request_date## : ##consumablerequest.request_date##\r\n##lang.consumablerequest.status## : ##consumablerequest.status##',\r\n'<p>##lang.consumable.entity## :##consumable.entity##<br /> <br />\r\n##lang.consumablerequest.requester## : ##consumablerequest.requester##<br />\t\r\n##lang.consumablerequest.consumabletype## : ##consumablerequest.consumabletype##<br />\r\n##lang.consumablerequest.consumable## : ##consumablerequest.consumable##<br />\r\n##lang.consumablerequest.number## : ##consumablerequest.number##<br />\r\n##lang.consumablerequest.request_date## : ##consumablerequest.request_date##<br />\r\n##lang.consumablerequest.status## : ##consumablerequest.status##<br />');";
    $result = $DB->query($query);
    $query = "INSERT INTO `glpi_notifications`\r\n              VALUES (NULL, 'Consumable request', 0, 'PluginConsumablesRequest', 'ConsumableRequest',\r\n                     'mail','" . $itemtype . "', '', 1, 1, '" . date('Y-m-d H:i:s') . "');";
    $result = $DB->query($query);
    // Request validation
    $query_id = "INSERT INTO `glpi_notificationtemplates`(`name`, `itemtype`, `date_mod`, `comment`, `css`) VALUES ('Consumables Request Validation','PluginConsumablesRequest', NOW(),'','');";
    $result = $DB->query($query_id) or die($DB->error());
    $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginConsumablesRequest' AND `name` = 'Consumables Request Validation'";
    $result = $DB->query($query_id) or die($DB->error());
    $itemtype = $DB->result($result, 0, 'id');
    $query = "INSERT INTO `glpi_notificationtemplatetranslations`\r\nVALUES(NULL, '" . $itemtype . "', '','##consumable.action## : ##consumable.entity##',\r\n'##lang.consumable.entity## :##consumable.entity##\r\n##lang.consumablerequest.requester## : ##consumablerequest.requester##\t\r\n##lang.consumablerequest.validator## : ##consumablerequest.validator##\t\r\n##lang.consumablerequest.consumabletype## : ##consumablerequest.consumabletype##\t\r\n##lang.consumablerequest.consumable## : ##consumablerequest.consumable##\r\n##lang.consumablerequest.number## : ##consumablerequest.number##\r\n##lang.consumablerequest.request_date## : ##consumablerequest.request_date##\r\n##lang.consumablerequest.status## : ##consumablerequest.status##\r\n##lang.consumablerequest.comment## : ##consumablerequest.comment##',\r\n'<p>##lang.consumable.entity## :##consumable.entity##<br /> <br />\r\n##lang.consumablerequest.requester## : ##consumablerequest.requester##<br />\t\r\n##lang.consumablerequest.validator## : ##consumablerequest.validator##<br />\r\n##lang.consumablerequest.consumabletype## : ##consumablerequest.consumabletype##<br />\r\n##lang.consumablerequest.consumable## : ##consumablerequest.consumable##<br />\r\n##lang.consumablerequest.number## : ##consumablerequest.number##<br />\r\n##lang.consumablerequest.request_date## : ##consumablerequest.request_date##<br />\r\n##lang.consumablerequest.status## : ##consumablerequest.status##<br />\r\n##lang.consumablerequest.comment## : ##consumablerequest.comment##<br />');";
    $result = $DB->query($query);
    $query = "INSERT INTO `glpi_notifications`\r\n              VALUES (NULL, 'Consumable request validation', 0, 'PluginConsumablesRequest', 'ConsumableResponse',\r\n                     'mail','" . $itemtype . "','', 1, 1, '" . date('Y-m-d H:i:s') . "');";
    $result = $DB->query($query);
    $migration->executeMigration();
    return true;
}
开发者ID:AircraftRu,项目名称:consumables,代码行数:35,代码来源:install.php

示例3: 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;
 }
开发者ID:publik1974,项目名称:fields,代码行数:25,代码来源:field.class.php

示例4: plugin_ticketmail_install

function plugin_ticketmail_install()
{
    global $DB;
    $migration = new Migration(100);
    //Fresh install
    if (!TableExists('glpi_plugin_ticketmail_profiles')) {
        $query = "CREATE TABLE `glpi_plugin_ticketmail_profiles` (\n\t\t\t\t\t`id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',\n\t\t\t\t\t`show_ticketmail_onglet` char(1) collate utf8_unicode_ci default NULL,\n\t\t\t\t\tPRIMARY KEY  (`id`)\n\t\t\t\t  ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->queryOrDie($query, $DB->error());
        $migration->executeMigration();
        include_once GLPI_ROOT . "/plugins/ticketmail/inc/profile.class.php";
        PluginTicketmailProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']);
    } else {
        // Since v0.84 remove "profiles_id" column and use "id"
        if (FieldExists('glpi_plugin_ticketmail_profiles', 'profiles_id')) {
            $drop_column_query = "ALTER TABLE glpi_plugin_ticketmail_profiles DROP COLUMN `id`;";
            $rename_column_query = "ALTER TABLE glpi_plugin_ticketmail_profiles\n\t\t\t\t\t\t\t\t\tCHANGE profiles_id id int(11) NOT NULL default '0'\n\t\t\t\t\t\t\t\t\tCOMMENT 'RELATION to glpi_profiles (id)';";
            $DB->queryOrDie($drop_column_query, $DB->error());
            $DB->queryOrDie($rename_column_query, $DB->error());
            $add_primarykey_query = "ALTER TABLE glpi_plugin_ticketmail_profiles\n\t\t\t\t\t\t\t\t\t ADD PRIMARY KEY (id);";
            $drop_old_index_query = "ALTER TABLE glpi_plugin_ticketmail_profiles\n\t\t\t\t\t\t\t\t\t DROP INDEX profiles_id;";
            $DB->queryOrDie($add_primarykey_query, $DB->error());
            $DB->queryOrDie($drop_old_index_query, $DB->error());
        }
    }
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:26,代码来源:hook.php

示例5: install

 /**
  * Install or update fields
  *
  * @param Migration $migration Migration instance
  * @param string    $version   Plugin current version
  *
  * @return boolean
  */
 static function install(Migration $migration, $version)
 {
     global $DB;
     $obj = new self();
     $table = $obj->getTable();
     if (!TableExists($table)) {
         $migration->displayMessage(sprintf(__("Installing %s"), $table));
         $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n                  `id`                         INT(11)       NOT NULL auto_increment,\n                  `plugin_fields_itemtype`     VARCHAR(30)  NOT NULL,\n                  `plugin_fields_items_id`     INT(11)      NOT NULL,\n                  `language`                   VARCHAR(5)   NOT NULL,\n                  `label`                      VARCHAR(255) DEFAULT NULL,\n                  PRIMARY KEY                  (`id`),\n                  KEY `plugin_fields_itemtype` (`plugin_fields_itemtype`),\n                  KEY `plugin_fields_items_id` (`plugin_fields_items_id`),\n                  KEY `language`               (`language`),\n                  UNIQUE KEY `unicity` (`plugin_fields_itemtype`, `plugin_fields_items_id`, `language`)\n               ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->query($query) or die($DB->error());
     }
     $migration->displayMessage("Updating {$table}");
     $migration->executeMigration();
     return true;
 }
开发者ID:pluginsGLPI,项目名称:fields,代码行数:22,代码来源:labeltranslation.class.php

示例6: update421to422

/**
 * Update from 4.2.1 to 4.2.2
 *
 * @return bool for success (will die for most error)
 * */
function update421to422()
{
    global $DB;
    $migration = new Migration('422');
    $query = "SELECT * FROM `glpi_plugin_positions_positions`";
    $result_query = $DB->query($query);
    while ($data = $DB->fetch_array($result_query)) {
        if (!($itemclass = getAllDatasFromTable(getTableForItemType($data['itemtype']), "`id` = " . $data['items_id']))) {
            $query = "DELETE FROM `glpi_plugin_positions_positions` WHERE `items_id` =" . $data['items_id'] . " AND `itemtype` = '" . $data['itemtype'] . "'";
            $DB->queryOrDie($query);
            continue;
        }
        $itemclass = reset($itemclass);
        $query = "UPDATE `glpi_plugin_positions_positions` SET `locations_id` = " . $itemclass['locations_id'] . " WHERE `items_id` =" . $data['items_id'] . " AND `itemtype` = '" . $data['itemtype'] . "'";
        $DB->queryOrDie($query, "ADD fields locations_ids for glpi_plugin_positions_positions");
    }
    $migration->executeMigration();
    return true;
}
开发者ID:nsautier,项目名称:positions,代码行数:24,代码来源:update_421_422.php

示例7: plugin_winadminpassword_install

function plugin_winadminpassword_install()
{
    global $DB;
    $migration = new Migration(100);
    if (!TableExists("glpi_plugin_winadminpassword_profiles")) {
        $query_profile = "CREATE TABLE IF NOT EXISTS `glpi_plugin_winadminpassword_profiles` (\n\t                        `id` int(11) NOT NULL,\n\t                        `profile` varchar(255) default NULL,\n\t                        `use` tinyint(1) default 0,\n\t                        PRIMARY KEY (`id`)\n\t                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query_profile, $DB->error());
        $migration->migrationOneTable("glpi_plugin_winadminpassword_profiles");
        // Give right to current Profile
        include_once GLPI_ROOT . '/plugins/winadminpassword/inc/profile.class.php';
        $prof = new PluginWinadminpasswordProfile();
        $prof->add(array('id' => $_SESSION['glpiactiveprofile']['id'], 'profile' => $_SESSION['glpiactiveprofile']['name'], 'use' => 1));
    }
    if (!TableExists("glpi_plugin_winadminpassword_configs")) {
        $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_winadminpassword_configs` (\n\t                        `id` int(11) NOT NULL auto_increment,\n\t                        `key` varchar(255) collate utf8_unicode_ci default NULL,\n\t\t\t\t`length` int(11) default 12,\n\t\t\t\t`algo` int(11) default 1,\n\t\t\t\t`size` int(11) default 14,\n\t\t\t\t`color` varchar(255) collate utf8_unicode_ci,\n\t                        PRIMARY KEY  (`id`)\n\t                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query, $DB->error());
    }
    $migration->executeMigration();
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:20,代码来源:hook.php

示例8: array

$types = array(1 => __('MAC'), 2 => __('IP'), 3 => __('Serial number'));
if (isset($_POST["delete"]) && isset($_POST['id'])) {
    $query = "DELETE\n             FROM `glpi_plugin_reports_doublons_backlists`\n             WHERE `id` = '" . $_POST['id'] . "'";
    $DB->query($query);
} else {
    if (isset($_POST["add"]) && isset($_POST["type"]) && isset($_POST["addr"]) && strlen($_POST["addr"])) {
        $query = "INSERT INTO `glpi_plugin_reports_doublons_backlists`\n             SET `type` = '" . $_POST["type"] . "',\n                 `addr` = '" . trim($_POST["addr"]) . "',\n                 `comment` = '" . trim($_POST["comment"]) . "'";
        $DB->query($query);
    }
}
// Initial creation
if (TableExists("glpi_plugin_reports_doublons_backlist")) {
    $migration = new Migration(160);
    $migration->renameTable("glpi_plugin_reports_doublons_backlist", "glpi_plugin_reports_doublons_backlists");
    $migration->changeField("glpi_plugin_reports_doublons_backlists", "ID", "id", 'autoincrement');
    $migration->executeMigration();
} else {
    if (!TableExists("glpi_plugin_reports_doublons_backlists")) {
        $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_reports_doublons_backlists` (\n               `id` int(11) NOT NULL AUTO_INCREMENT,\n               `type` int(11) NOT NULL DEFAULT '0',\n               `addr` varchar(255) DEFAULT NULL,\n               `comment` varchar(255) DEFAULT NULL,\n               PRIMARY KEY (`id`)\n             ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
        $query = "INSERT INTO`glpi_plugin_reports_doublons_backlists`\n                    (`type`, `addr`, `comment`)\n             VALUES (1, '44:45:53:54:42:00', 'Nortel IPSECSHM Adapter'),\n                    (1, 'BA:D0:BE:EF:FA:CE', 'GlobeTrotter Module 3G+ Network Card'),\n                    (1, '00:53:45:00:00:00', 'WAN (PPP/SLIP) Interface'),\n                    (1, '80:00:60:0F:E8:00', 'Windows Mobile-based'),\n                    (2, '127.0.0.1', 'loopback'),\n                    (3, 'INVALID', 'from OCSNG'),\n                    (3, 'XxXxXxX', 'from IBM')";
        $DB->query($query);
    }
}
// ---------- Form ------------
echo "<div class='center'><table class='tab_cadre' cellpadding='5'>\n";
echo "<tr class='tab_bg_1 center'><th><a href='" . GLPI_ROOT . "/plugins/reports/front/config.form.php'>" . __('Reports plugin configuration', 'reports') . "</a><br />&nbsp;<br />" . sprintf(__('%1$s: %2$s'), __('Report configuration', 'reports'), __('Duplicate computers', 'reports')) . "</th></tr>\n";
$plug = new Plugin();
if ($plug->isActivated('reports')) {
    echo "<tr class='tab_bg_1 center'><td>";
    echo "<a href='./doublons.php'>" . sprintf(__('%1$s - %2$s'), __('Report'), __('Duplicate computers', 'reports')) . "</a>";
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:doublons.config.php

示例9: plugin_archires_updateTo210

function plugin_archires_updateTo210()
{
    $migration = new Migration(210);
    $migration->changeField("glpi_plugin_archires_appliancequeries", "appliances_id", "plugin_appliances_appliances_id", 'integer', array('comment' => 'RELATION to glpi_plugin_appliances (id)'));
    $migration->executeMigration();
}
开发者ID:geldarr,项目名称:hack-space,代码行数:6,代码来源:hook.php

示例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();
     }
 }
开发者ID:equinoxefr,项目名称:order,代码行数:73,代码来源:order_item.class.php

示例11: plugin_ocsinventoryng_upgrademassocsimport14to15

function plugin_ocsinventoryng_upgrademassocsimport14to15()
{
    global $DB;
    $migration = new Migration(15);
    $migration->addField("glpi_plugin_massocsimport_threads", "not_unique_machines_number", 'integer');
    $migration->addField("glpi_plugin_massocsimport_threads", "link_refused_machines_number", 'integer');
    $migration->addField("glpi_plugin_massocsimport_threads", "entities_id", 'integer');
    $migration->addField("glpi_plugin_massocsimport_threads", "rules_id", 'text');
    $migration->addField("glpi_plugin_massocsimport_configs", "allow_ocs_update", 'bool');
    $migration->addField("glpi_plugin_massocsimport_notimported", "reason", 'integer');
    if (!countElementsInTable('glpi_displaypreferences', "`itemtype`='PluginMassocsimportNotimported'\n                               AND `num`='10' AND `users_id`='0'")) {
        $query = "INSERT INTO `glpi_displaypreferences`\n                (`itemtype`, `num`, `rank`, `users_id`)\n                VALUES ('PluginMassocsimportNotimported', 10, 9, 0)";
        $DB->queryOrDie($query, "1.5 insert into glpi_displaypreferences " . $DB->error());
    }
    $migration->addField("glpi_plugin_massocsimport_notimported", "serial", 'string', array('value' => ''));
    $migration->addField("glpi_plugin_massocsimport_notimported", "comment", "TEXT NOT NULL");
    $migration->addField("glpi_plugin_massocsimport_notimported", "rules_id", 'text');
    $migration->addField("glpi_plugin_massocsimport_notimported", "entities_id", 'integer');
    $migration->addField("glpi_plugin_massocsimport_details", "entities_id", 'integer');
    $migration->addField("glpi_plugin_massocsimport_details", "rules_id", 'text');
    $query = "SELECT id " . "FROM `glpi_notificationtemplates` " . "WHERE `itemtype`='PluginMassocsimportNotimported'";
    $result = $DB->query($query);
    if (!$DB->numrows($result)) {
        //Add template
        $query = "INSERT INTO `glpi_notificationtemplates` " . "VALUES (NULL, 'Computers not imported', 'PluginMassocsimportNotimported',\n                        NOW(), '', '');";
        $DB->queryOrDie($query, $DB->error());
        $templates_id = $DB->insert_id();
        $query = "INSERT INTO `glpi_notificationtemplatetranslations` " . "VALUES(NULL, {$templates_id}, '', '##lang.notimported.action## : ##notimported.entity##'," . " '\r\n\n##lang.notimported.action## :&#160;##notimported.entity##\n\n" . "##FOREACHnotimported##&#160;\n##lang.notimported.reason## : ##notimported.reason##\n" . "##lang.notimported.name## : ##notimported.name##\n" . "##lang.notimported.deviceid## : ##notimported.deviceid##\n" . "##lang.notimported.tag## : ##notimported.tag##\n##lang.notimported.serial## : ##notimported.serial## \r\n\n" . " ##notimported.url## \n##ENDFOREACHnotimported## \r\n', '&lt;p&gt;##lang.notimported.action## :&#160;##notimported.entity##&lt;br /&gt;&lt;br /&gt;" . "##FOREACHnotimported##&#160;&lt;br /&gt;##lang.notimported.reason## : ##notimported.reason##&lt;br /&gt;" . "##lang.notimported.name## : ##notimported.name##&lt;br /&gt;" . "##lang.notimported.deviceid## : ##notimported.deviceid##&lt;br /&gt;" . "##lang.notimported.tag## : ##notimported.tag##&lt;br /&gt;" . "##lang.notimported.serial## : ##notimported.serial##&lt;/p&gt;\r\n&lt;p&gt;&lt;a href=\"##infocom.url##\"&gt;" . "##notimported.url##&lt;/a&gt;&lt;br /&gt;##ENDFOREACHnotimported##&lt;/p&gt;');";
        $DB->queryOrDie($query, $DB->error());
        $query = "INSERT INTO `glpi_notifications`\n                VALUES (NULL, 'Computers not imported', 0, 'PluginMassocsimportNotimported',\n                        'not_imported', 'mail'," . $templates_id . ", '', 1, 1, NOW());";
        $DB->queryOrDie($query, $DB->error());
    }
    $migration->executeMigration();
}
开发者ID:geldarr,项目名称:hack-space,代码行数:34,代码来源:hook.php

示例12: plugin_pdf_install

function plugin_pdf_install()
{
    global $DB;
    $migration = new Migration('0.84');
    if (!TableExists('glpi_plugin_pdf_profiles')) {
        $query = "CREATE TABLE IF NOT EXISTS\n               `glpi_plugin_pdf_profiles` (\n                  `id` int(11) NOT NULL,\n                  `profile` varchar(255) default NULL,\n                  `use` tinyint(1) default 0,\n                  PRIMARY KEY (`id`)\n               ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDir($query, $DB->error());
    } else {
        if (FieldExists('glpi_plugin_pdf_profiles', 'ID')) {
            //< 0.7.0
            $migration->changeField('glpi_plugin_pdf_profiles', 'ID', 'id', 'autoincrement');
        }
    }
    if (!TableExists('glpi_plugin_pdf_preference')) {
        $query = "CREATE TABLE IF NOT EXISTS\n               `glpi_plugin_pdf_preferences` (\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\n                  `users_id` int(11) NOT NULL COMMENT 'RELATION to glpi_users (id)',\n                  `itemtype` VARCHAR(100) NOT NULL COMMENT 'see define.php *_TYPE constant',\n                  `tabref` varchar(255) NOT NULL COMMENT 'ref of tab to display, or plugname_#, or option name',\n                  PRIMARY KEY (`id`)\n               ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
    } else {
        $migration->renameTable('glpi_plugin_pdf_preference', 'glpi_plugin_pdf_preferences');
        // 0.6.0
        if (FieldExists('glpi_plugin_pdf_preferences', 'user_id')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'user_id', 'users_id', 'integer', array('comment' => 'RELATION to glpi_users (id)'));
        }
        // 0.6.1
        if (FieldExists('glpi_plugin_pdf_preferences', 'FK_users')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'FK_users', 'users_id', 'integer', array('comment' => 'RELATION to glpi_users (id)'));
        }
        // 0.6.0
        if (FieldExists('glpi_plugin_pdf_preferences', 'cat')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'cat', 'itemtype', 'VARCHAR(100) NOT NULL', array('comment' => 'see define.php *_TYPE constant'));
        }
        // 0.6.1
        if (FieldExists('glpi_plugin_pdf_preferences', 'device_type')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'device_type', 'itemtype', 'VARCHAR(100) NOT NULL', array('comment' => 'see define.php *_TYPE constant'));
        }
        // 0.6.0
        if (FieldExists('glpi_plugin_pdf_preferences', 'table_num')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'table_num', 'tabref', 'string', array('comment' => 'ref of tab to display, or plugname_#, or option name'));
        }
        $migration->executeMigration();
    }
    // Give right to current Profile
    include_once GLPI_ROOT . '/plugins/pdf/inc/profile.class.php';
    $prof = new PluginPdfProfile();
    if (!$prof->getFromDB($_SESSION['glpiactiveprofile']['id'])) {
        $prof->add(array('id' => $_SESSION['glpiactiveprofile']['id'], 'profile' => $_SESSION['glpiactiveprofile']['name'], 'use' => 1));
    }
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:48,代码来源:hook.php

示例13: plugin_datainjection_update131_14

function plugin_datainjection_update131_14()
{
    global $DB;
    $migration = new Migration('1.4');
    $migration->addField('glpi_plugin_data_injection_models', 'float_format', 'bool');
    //Template recursivity : need standardize names in order to use privatePublicSwitch
    $migration->changeField('glpi_plugin_data_injection_models', 'user_id', 'FK_users', 'integer');
    $migration->changeField('glpi_plugin_data_injection_models', 'public', 'private', 'bool');
    $migration->migrationOneTable('glpi_plugin_data_injection_models');
    $sql = "UPDATE `glpi_plugin_data_injection_models`\n           SET `FK_entities` = '-1',\n               `private` = '1'\n           WHERE `private` = '0'";
    $DB->query($sql);
    $sql = "UPDATE `glpi_plugin_data_injection_models`\n           SET `private` = '0'\n           WHERE `private` = '1'\n                AND `FK_entities` > '0'";
    $DB->query($sql);
    $migration->addField('glpi_plugin_data_injection_models', 'recursive', 'bool');
    $sql = "UPDATE `glpi_plugin_data_injection_profiles`\n           SET `create_model` = `use_model`\n           WHERE `create_model` IS NULL";
    $DB->query($sql);
    $migration->dropField('glpi_plugin_data_injection_profiles', 'use_model');
    $migration->changeField('glpi_plugin_data_injection_profiles', 'create_model', 'model', 'char');
    $migration->executeMigration();
}
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:20,代码来源:hook.php

示例14: install

 static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     $config = new self();
     // Install
     if (!TableExists($table)) {
         $migration->displayMessage("Installing {$table}");
         //Install
         $query = "CREATE TABLE `{$table}` (\n                     `id` int(11) NOT NULL auto_increment,\n                     `purge_computer_software_install` int(11) NOT NULL default '0',\n                     `purge_software_version_install` int(11) NOT NULL default '0',\n                     `purge_infocom_creation` int(11) NOT NULL default '0',\n                     `purge_profile_user` int(11) NOT NULL default '0',\n                     `purge_group_user` int(11) NOT NULL default '0',\n                     `purge_webservices_logs` int(11) NOT NULL default '0',\n                     `purge_ocsid_changes` int(11) NOT NULL default '0',\n                     `purge_ocsimport` int(11) NOT NULL default '0',\n                     `purge_ocslink` int(11) NOT NULL default '0',\n                     `purge_ocsdelete` int(11) NOT NULL default '0',\n                     `purge_adddevice` tinyint(1) NOT NULL default '0',\n                     `purge_updatedevice` tinyint(1) NOT NULL default '0',\n                     `purge_deletedevice` tinyint(1) NOT NULL default '0',\n                     `purge_connectdevice` tinyint(1) NOT NULL default '0',\n                     `purge_disconnectdevice` tinyint(1) NOT NULL default '0',\n                     `purge_userdeletedfromldap` tinyint(1) NOT NULL default '0',\n                     `purge_addrelation` tinyint(1) NOT NULL default '0',\n                     `purge_deleterelation` tinyint(1) NOT NULL default '0',\n                     `purge_createitem` tinyint(1) NOT NULL default '0',\n                     `purge_deleteitem` tinyint(1) NOT NULL default '0',\n                     `purge_restoreitem` tinyint(1) NOT NULL default '0',\n                     `purge_updateitem` tinyint(1) NOT NULL default '0',\n                     `purge_comments` tinyint(1) NOT NULL default '0',\n                     `purge_datemod` tinyint(1) NOT NULL default '0',\n                     `purge_genericobject_unusedtypes` tinyint(1) NOT NULL default '0',\n                     `purge_all` tinyint(1) NOT NULL default '0',\n                     `purge_user_auth_changes` tinyint(1) NOT NULL default '0',\n                     PRIMARY KEY  (`id`)\n                  ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->query($query) or die($DB->error());
         //Add config
         $config->add(array('id' => 1));
     }
     // Update
     if (TableExists($table)) {
         // for 0.84
         if (!FieldExists($table, "purge_genericobject_unusedtypes")) {
             $migration->displayMessage("Updating {$table} adding field purge_genericobject_unusedtypes");
             $migration->addField($table, "purge_genericobject_unusedtypes", "tinyint(1) NOT NULL default '0'", array('after' => "purge_datemod", 'update' => "0"));
         }
         // for 0.84.1
         if (!FieldExists($table, "purge_all")) {
             $migration->displayMessage("Updating {$table} adding fiel purge_all");
             $migration->addField($table, "purge_all", "tinyint(1) NOT NULL default '0'", array('after' => "purge_genericobject_unusedtypes", 'update' => "0"));
         }
         $migration->addfield($table, 'purge_user_auth_changes', 'bool');
     }
     $migration->executeMigration();
     return true;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:config.class.php


注:本文中的Migration::executeMigration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。