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


PHP Migration::addField方法代码示例

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


在下文中一共展示了Migration::addField方法的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;
 }
开发者ID:publik1974,项目名称:fields,代码行数:25,代码来源:field.class.php

示例2: install

 static function install(Migration $mig)
 {
     global $DB;
     $table = 'glpi_plugin_behaviors_configs';
     if (!TableExists($table)) {
         //not installed
         $query = "CREATE TABLE `" . $table . "`(\n                     `id` int(11) NOT NULL,\n                     `use_requester_item_group` tinyint(1) NOT NULL default '0',\n                     `use_requester_user_group` tinyint(1) NOT NULL default '0',\n                     `is_ticketsolutiontype_mandatory` tinyint(1) NOT NULL default '0',\n                     `is_ticketrealtime_mandatory` tinyint(1) NOT NULL default '0',\n                     `is_requester_mandatory` tinyint(1) NOT NULL default '0',\n                     `is_ticketdate_locked` tinyint(1) NOT NULL default '0',\n                     `use_assign_user_group` tinyint(1) NOT NULL default '0',\n                     `tickets_id_format` VARCHAR(15) NULL,\n                     `remove_from_ocs` tinyint(1) NOT NULL default '0',\n                     `add_notif` tinyint(1) NOT NULL default '0',\n                     `use_lock` tinyint(1) NOT NULL default '0',\n                     `single_tech_mode` int(11) NOT NULL default '0',\n                     `date_mod` datetime default NULL,\n                     `comment` text,\n                     PRIMARY KEY  (`id`)\n                   ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
         $DB->queryOrDie($query, __('Error in creating glpi_plugin_behaviors_configs', 'behaviors') . "<br>" . $DB->error());
         $query = "INSERT INTO " . `{$table}` . "\n                         (id, date_mod)\n                   VALUES (1, NOW())";
         $DB->queryOrDie($query, __('Error during update glpi_plugin_behaviors_configs', 'behaviors') . "<br>" . $DB->error());
     } else {
         // Upgrade
         $mig->addField($table, 'tickets_id_format', 'string');
         $mig->addField($table, 'remove_from_ocs', 'bool');
         $mig->addField($table, 'is_requester_mandatory', 'bool');
         // version 0.78.0 - feature #2801 Forbid change of ticket's creation date
         $mig->addField($table, 'is_ticketdate_locked', 'bool');
         // Version 0.80.0 - set_use_date_on_state now handle in GLPI
         $mig->dropField($table, 'set_use_date_on_state');
         // Version 0.80.4 - feature #3171 additional notifications
         $mig->addField($table, 'add_notif', 'bool');
         // Version 0.83.0 - groups now have is_requester and is_assign attribute
         $mig->dropField($table, 'sql_user_group_filter');
         $mig->dropField($table, 'sql_tech_group_filter');
         // Version 0.83.1 - prevent update on ticket updated by another user
         $mig->addField($table, 'use_lock', 'bool');
         // Version 0.83.4 - single tech/group #3857
         $mig->addField($table, 'single_tech_mode', 'integer');
     }
     return true;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:31,代码来源:config.class.php

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

示例4: plugin_mreporting_install

function plugin_mreporting_install()
{
    global $DB;
    //get version
    $plugin = new Plugin();
    $found = $plugin->find("name = 'mreporting'");
    $plugin_mreporting = array_shift($found);
    //init migration
    $migration = new Migration($plugin_mreporting['version']);
    //create profiles table
    $queries = array();
    $queries[] = "CREATE TABLE IF NOT EXISTS `glpi_plugin_mreporting_profiles` (\n      `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,\n      `profiles_id` VARCHAR(45) NOT NULL,\n      `reports` CHAR(1),\n      `config` CHAR(1),\n   PRIMARY KEY (`id`)\n   )\n   ENGINE = MyISAM;";
    //create configuration table
    $queries[] = "CREATE TABLE IF NOT EXISTS `glpi_plugin_mreporting_configs` (\n   `id` int(11) NOT NULL auto_increment,\n   `name` varchar(255) collate utf8_unicode_ci default NULL,\n   `classname` varchar(255) collate utf8_unicode_ci default NULL,\n   `is_active` tinyint(1) NOT NULL default '0',\n   `is_notified` tinyint(1) NOT NULL default '1',\n   `show_graph` tinyint(1) NOT NULL default '0',\n   `show_area` tinyint(1) NOT NULL default '0',\n   `spline` tinyint(1) NOT NULL default '0',\n   `show_label` VARCHAR(10) default NULL,\n   `flip_data` tinyint(1) NOT NULL default '0',\n   `unit` VARCHAR(10) default NULL,\n   `default_delay` VARCHAR(10) default NULL,\n   `condition` VARCHAR(255) default NULL,\n   `graphtype` VARCHAR(255) default 'GLPI',\n   PRIMARY KEY  (`id`),\n   KEY `is_active` (`is_active`)\n   ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
    $queries[] = "CREATE TABLE  IF NOT EXISTS `glpi_plugin_mreporting_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   PRIMARY KEY  (`id`),\n   KEY `users_id` (`users_id`)\n   ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
    // add display preferences
    $query_display_pref = "SELECT id \n      FROM glpi_displaypreferences\n      WHERE itemtype = 'PluginMreportingConfig'";
    $res_display_pref = $DB->query($query_display_pref);
    if ($DB->numrows($res_display_pref) == 0) {
        $queries[] = "INSERT INTO `glpi_displaypreferences` \n         VALUES (NULL,'PluginMreportingConfig','2','2','0');";
        $queries[] = "INSERT INTO `glpi_displaypreferences` \n         VALUES (NULL,'PluginMreportingConfig','3','3','0');";
        $queries[] = "INSERT INTO `glpi_displaypreferences` \n         VALUES (NULL,'PluginMreportingConfig','4','4','0');";
        $queries[] = "INSERT INTO `glpi_displaypreferences` \n         VALUES (NULL,'PluginMreportingConfig','5','5','0');";
        $queries[] = "INSERT INTO `glpi_displaypreferences` \n         VALUES (NULL,'PluginMreportingConfig','6','6','0');";
        $queries[] = "INSERT INTO `glpi_displaypreferences` \n         VALUES (NULL,'PluginMreportingConfig','8','8','0');";
    }
    $queries[] = "CREATE TABLE IF NOT EXISTS `glpi_plugin_mreporting_notifications` (\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      `notepad` longtext collate utf8_unicode_ci,\n      `date_envoie` DATE DEFAULT NULL,\n      `notice`INT(11) NOT NULL DEFAULT 0,\n      `alert` INT(11) NOT NULL DEFAULT 0,\n      `comment` text collate utf8_unicode_ci,\n      `date_mod` datetime default NULL,\n      `is_deleted` tinyint(1) NOT NULL default '0',\n      PRIMARY KEY  (`id`)\n      ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
    foreach ($queries as $query) {
        $DB->query($query);
    }
    // == Update to 2.1 ==
    if (!FieldExists('glpi_plugin_mreporting_configs', 'is_notified')) {
        $migration->addField('glpi_plugin_mreporting_configs', 'is_notified', 'tinyint(1) NOT NULL default "1"', array('after' => 'is_active'));
        $migration->migrationOneTable('glpi_plugin_mreporting_configs');
    }
    require_once "inc/profile.class.php";
    PluginMreportingProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    $rep_files_mreporting = GLPI_PLUGIN_DOC_DIR . "/mreporting";
    if (!is_dir($rep_files_mreporting)) {
        mkdir($rep_files_mreporting);
    }
    $notifications_folder = GLPI_PLUGIN_DOC_DIR . "/mreporting/notifications";
    if (!is_dir($notifications_folder)) {
        mkdir($notifications_folder);
    }
    require_once "inc/notification.class.php";
    PluginMreportingNotification::install();
    CronTask::Register('PluginMreportingNotification', 'SendNotifications', MONTH_TIMESTAMP);
    require_once "inc/baseclass.class.php";
    require_once "inc/common.class.php";
    require_once "inc/config.class.php";
    $config = new PluginMreportingConfig();
    $config->createFirstConfig();
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:55,代码来源:hook.php

示例5: install

 static function install(Migration $migration)
 {
     global $DB;
     if (!$DB->query("CREATE TABLE IF NOT EXISTS `glpi_plugin_talk_userprefs` (\n            `id`                INT(11) NOT NULL auto_increment,\n            `users_id`          INT(11) NOT NULL default '0',\n            `talk_tab`   TINYINT(1) NOT NULL default '1',\n            `old_tabs`   TINYINT(1) NOT NULL default '1',\n            `split_view` TINYINT(1) NOT NULL default '0',\n            PRIMARY KEY  (`id`),\n            UNIQUE KEY (`users_id`),\n            KEY `talk_tab` (`talk_tab`),\n            KEY `split_view` (`split_view`)\n      ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci")) {
         return false;
     }
     if (!FieldExists('glpi_plugin_talk_userprefs', 'old_tabs')) {
         $migration->addField('glpi_plugin_talk_userprefs', 'old_tabs', 'bool');
         $migration->migrationOneTable('glpi_plugin_talk_userprefs');
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:11,代码来源:userpref.class.php

示例6: install

 /**
  * Install or update containers
  *
  * @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                  `name`         VARCHAR(255)   DEFAULT NULL,\n                  `label`        VARCHAR(255)   DEFAULT NULL,\n                  `itemtypes`     LONGTEXT   DEFAULT NULL,\n                  `type`         VARCHAR(255)   DEFAULT NULL,\n                  `subtype`      VARCHAR(255) DEFAULT NULL,\n                  `entities_id`  INT(11)        NOT NULL DEFAULT '0',\n                  `is_recursive` TINYINT(1)     NOT NULL DEFAULT '0',\n                  `is_active`    TINYINT(1)     NOT NULL DEFAULT '0',\n                  PRIMARY KEY    (`id`),\n                  KEY            `entities_id`  (`entities_id`)\n               ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->query($query) or die($DB->error());
     }
     // multiple itemtype for one container
     if (!FieldExists($table, "itemtypes")) {
         $migration->changeField($table, 'itemtype', 'itemtypes', 'longtext');
         $migration->migrationOneTable($table);
         $query = "UPDATE `{$table}` SET `itemtypes` = CONCAT('[\"', `itemtypes`, '\"]')";
         $DB->query($query) or die($DB->error());
     }
     //add display preferences for this class
     $d_pref = new DisplayPreference();
     $found = $d_pref->find("itemtype = '" . __CLASS__ . "'");
     if (count($found) == 0) {
         for ($i = 2; $i <= 5; $i++) {
             $DB->query("REPLACE INTO glpi_displaypreferences VALUES\n               (NULL, '" . __CLASS__ . "', {$i}, " . ($i - 1) . ", 0)");
         }
     }
     if (!FieldExists($table, "subtype")) {
         $migration->addField($table, 'subtype', 'VARCHAR(255) DEFAULT NULL', array('after' => 'type'));
         $migration->migrationOneTable($table);
     }
     $migration->displayMessage(__("Updating generated containers files", "fields"));
     // -> 0.90-1.3: generated class moved
     // OLD path: GLPI_ROOT."/plugins/fields/inc/$class_filename"
     // NEW path: PLUGINFIELDS_CLASS_PATH . "/$class_filename"
     $obj = new self();
     $containers = $obj->find();
     foreach ($containers as $container) {
         //First, drop old fields from plugin directories
         $itemtypes = count($container['itemtypes']) > 0 ? json_decode($container['itemtypes'], true) : array();
         foreach ($itemtypes as $itemtype) {
             $class_filename = strtolower($itemtype . preg_replace('/s$/', '', $container['name']) . ".class.php");
             if (file_exists(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}")) {
                 unlink(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}");
             }
             $injclass_filename = strtolower($itemtype . preg_replace('/s$/', '', $container['name']) . "injection.class.php");
             if (file_exists(GLPI_ROOT . "/plugins/fields/inc/{$injclass_filename}")) {
                 unlink(GLPI_ROOT . "/plugins/fields/inc/{$injclass_filename}");
             }
         }
         //Second, create new files
         self::generateTemplate($container);
     }
     return true;
 }
开发者ID:pluginsGLPI,项目名称:fields,代码行数:61,代码来源:container.class.php

示例7: plugin_escalation_install

function plugin_escalation_install()
{
    global $DB;
    if (!TableExists("glpi_plugin_escalation_groups_groups")) {
        $empty_sql = "plugin_escalation-empty.sql";
        $DB_file = GLPI_ROOT . "/plugins/escalation/install/mysql/{$empty_sql}";
        $DBf_handle = fopen($DB_file, "rt");
        $sql_query = fread($DBf_handle, filesize($DB_file));
        fclose($DBf_handle);
        foreach (explode(";\n", "{$sql_query}") as $sql_line) {
            if (Toolbox::get_magic_quotes_runtime()) {
                $sql_line = Toolbox::stripslashes_deep($sql_line);
            }
            if (!empty($sql_line)) {
                $DB->query($sql_line);
            }
        }
    } else {
        if (!TableExists("glpi_plugin_escalation_configs")) {
            $DB->query("CREATE TABLE `glpi_plugin_escalation_configs` (\n            `id` int(11) NOT NULL AUTO_INCREMENT,\n            `entities_id` int(11) NOT NULL DEFAULT '0',\n            `unique_assigned` varchar(255) DEFAULT NULL,\n            `workflow`  varchar(255) DEFAULT NULL,\n            `limitgroup`  varchar(255) DEFAULT NULL,\n            PRIMARY KEY (`id`)\n         ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
            $DB->query("INSERT INTO `glpi_plugin_escalation_configs`\n            (`id` ,`entities_id` ,`unique_assigned` ,`workflow`, `limitgroup`)\n         VALUES (NULL , '0', '0', '0', '0');");
        }
        if (!TableExists("glpi_plugin_escalation_profiles")) {
            $DB->query("CREATE TABLE `glpi_plugin_escalation_profiles` (\n           `profiles_id` int(11) NOT NULL DEFAULT '0',\n           `bypassworkflow` char(1) COLLATE utf8_unicode_ci DEFAULT NULL,\n           `copyticket` char(1) COLLATE utf8_unicode_ci DEFAULT NULL,\n           `copyticketonworkflow` char(1) COLLATE utf8_unicode_ci DEFAULT NULL\n         ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
        }
        if (!FieldExists('glpi_plugin_escalation_profiles', 'copyticket')) {
            $DB->query("ALTER TABLE `glpi_plugin_escalation_profiles` \n            ADD `copyticket` CHAR( 1 ) NULL ");
            $DB->query("ALTER TABLE `glpi_plugin_escalation_profiles` \n            ADD `copyticketonworkflow` CHAR( 1 ) NULL ");
        }
        if (!FieldExists("glpi_plugin_escalation_configs", "limitgroup")) {
            $migration = new Migration(PLUGIN_ESCALATION_VERSION);
            $migration->addField('glpi_plugin_escalation_configs', "limitgroup", "varchar(255) DEFAULT NULL");
            $migration->migrationOneTable('glpi_plugin_escalation_configs');
            $DB->query("UPDATE `glpi_plugin_escalation_configs` \n            SET `limitgroup` = '0' WHERE `entities_id` =1");
        }
    }
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:38,代码来源:hook.php

示例8: 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                  `itemtype`     VARCHAR(255)   DEFAULT NULL,\n                  `type`         VARCHAR(255)   DEFAULT NULL,\n                  `subtype`      VARCHAR(255) DEFAULT NULL,\n                  `entities_id`  INT(11)        NOT NULL DEFAULT '0',\n                  `is_recursive` TINYINT(1)     NOT NULL DEFAULT '0',\n                  `is_active`    TINYINT(1)     NOT NULL DEFAULT '0',\n                  PRIMARY KEY    (`id`),\n                  KEY            `entities_id`  (`entities_id`)\n               ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->query($query) or die($DB->error());
     }
     //add display preferences for this class
     $d_pref = new DisplayPreference();
     $found = $d_pref->find("itemtype = '" . __CLASS__ . "'");
     if (count($found) == 0) {
         for ($i = 2; $i <= 5; $i++) {
             $DB->query("INSERT INTO glpi_displaypreferences VALUES\n               (NULL, '" . __CLASS__ . "', {$i}, " . ($i - 1) . ", 0)");
         }
     }
     if (!FieldExists($table, "subtype")) {
         $migration->addField($table, 'subtype', 'VARCHAR(255) DEFAULT NULL', array('after' => 'type'));
         $migration->migrationOneTable($table);
     }
     return true;
 }
开发者ID:publik1974,项目名称:fields,代码行数:24,代码来源:container.class.php

示例9: 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);
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:25,代码来源:client.class.php

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

示例11: plugin_archires_updateTo180


//.........这里部分代码省略.........
    $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());
    $query = "UPDATE `glpi_plugin_archires_querytypes`\n             SET `querytype` = 'PluginArchiresApplianceQuery'\n             WHERE `querytype` = 2";
    $DB->queryOrDie($query, __('1.8.0 update glpi_plugin_archires_querytypes (querytype) ', 'archires') . $DB->error());
    $migration->dropKey("glpi_plugin_archires_networkinterfacecolors", "iface");
    $migration->changeField("glpi_plugin_archires_networkinterfacecolors", "ID", "id", 'autoincrement');
    $migration->changeField("glpi_plugin_archires_networkinterfacecolors", "iface", "networkinterfaces_id", 'integer', array('comment' => 'RELATION to glpi_networkinterfaces (id)'));
    $migration->addKey("glpi_plugin_archires_networkinterfacecolors", "networkinterfaces_id");
    $migration->changeField("glpi_plugin_archires_statecolors", "ID", "id", 'autoincrement');
    $migration->changeField("glpi_plugin_archires_statecolors", "state", "states_id", 'integer', array('comment' => 'RELATION to glpi_states (id)'));
    $migration->addKey("glpi_plugin_archires_statecolors", "states_id");
    $migration->changeField("glpi_plugin_archires_vlancolors", "ID", "id", 'autoincrement');
    $migration->changeField("glpi_plugin_archires_vlancolors", "vlan", "vlans_id", 'integer', array('comment' => 'RELATION to glpi_vlans (id)'));
    $migration->addKey("glpi_plugin_archires_vlancolors", "vlans_id");
    $migration->dropKey("glpi_plugin_archires_views", "deleted");
    $migration->dropKey("glpi_plugin_archires_views", "FK_entities");
    $migration->changeField("glpi_plugin_archires_views", "ID", "id", 'autoincrement');
    $migration->changeField("glpi_plugin_archires_views", "name", "name", 'string');
    $migration->changeField("glpi_plugin_archires_views", "FK_entities", "entities_id", 'integer');
    $migration->changeField("glpi_plugin_archires_views", "deleted", "is_deleted", 'bool');
    $migration->addKey("glpi_plugin_archires_views", "entities_id");
    $migration->addKey("glpi_plugin_archires_views", "is_deleted");
    $migration->changeField("glpi_plugin_archires_profiles", "ID", "id", 'autoincrement');
    $migration->addField("glpi_plugin_archires_profiles", "profiles_id", 'integer', array('comment' => 'RELATION to glpi_profiles (id)'));
    $migration->changeField("glpi_plugin_archires_profiles", "archires", "archires", 'char');
    $migration->addKey("glpi_plugin_archires_profiles", "profiles_id");
    $query = "DELETE\n             FROM `glpi_displaypreferences`\n             WHERE `itemtype` = 3000 AND `num` = 9";
    $DB->queryOrDie($query, __('1.8.0 delete glpi_displaypreferences (itemtype) ', 'archires') . $DB->error());
    $query = "DELETE\n             FROM `glpi_displaypreferences`\n             WHERE `itemtype` = 3001 AND `num` = 8";
    $DB->queryOrDie($query, __('1.8.0 delete glpi_displaypreferences (itemtype) ', 'archires') . $DB->error());
    $query = "DELETE\n             FROM `glpi_displaypreferences`\n             WHERE `itemtype` = 3002 AND `num` = 8";
    $DB->queryOrDie($query, __('1.8.0 delete glpi_displaypreferences (itemtype) ', 'archires') . $DB->error());
    $migration->executeMigration();
}
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:hook.php

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

示例13: 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) {
//.........这里部分代码省略.........
开发者ID:pluginsGLPI,项目名称:order,代码行数:101,代码来源:order.class.php

示例14: 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');
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:18,代码来源:appliance.class.php

示例15: 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


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