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


PHP Migration::migrationOneTable方法代码示例

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


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

示例1: install

 static function install(Migration $migration)
 {
     global $DB, $GENINVENTORYNUMBER_TYPES;
     $table = getTableForItemType(__CLASS__);
     if (TableExists("glpi_plugin_geninventorynumber_fields")) {
         //Only migrate itemtypes when it's only necessary, otherwise it breaks upgrade procedure !
         $migration->renameTable("glpi_plugin_geninventorynumber_fields", $table);
     }
     if (!TableExists($table)) {
         $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n            `id` int(11) NOT NULL auto_increment,\n            `plugin_geninventorynumber_configs_id` int(11) NOT NULL default '0',\n            `itemtype` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',\n            `template` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',\n            `is_active` tinyint(1) NOT NULL default '0',\n            `use_index` tinyint(1) NOT NULL default '0',\n            `index` bigint(20) NOT NULL default '0',\n            PRIMARY KEY  (`id`)\n            ) ENGINE=MyISAM  CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->query($query);
     } else {
         $migration->changeField($table, 'ID', 'id', 'autoincrement');
         $migration->changeField($table, 'config_id', 'plugin_geninventorynumber_configs_id', 'integer');
         if ($migration->changeField($table, 'device_type', 'itemtype', 'string')) {
             $migration->migrationOneTable($table);
             Plugin::migrateItemType(array(), array("glpi_displaypreferences"), array($table));
         }
         $migration->changeField($table, 'enabled', 'is_active', 'boolean');
         $migration->changeField($table, 'use_index', 'use_index', 'boolean');
         $migration->migrationOneTable($table);
     }
     $field = new self();
     foreach ($GENINVENTORYNUMBER_TYPES as $type) {
         if (!countElementsInTable($table, "`itemtype`='{$type}'")) {
             $input["plugin_geninventorynumber_configs_id"] = 1;
             $input["itemtype"] = $type;
             $input["template"] = "<#######>";
             $input["is_active"] = 0;
             $input["index"] = 0;
             $field->add($input);
         }
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:34,代码来源:configfield.class.php

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

示例3: install

 public static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     if (!TableExists($table) && !TableExists("glpi_dropdown_plugin_order_taxes")) {
         $migration->displayMessage("Installing {$table}");
         //Install
         $query = "CREATE TABLE `glpi_plugin_order_ordertaxes` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `name` varchar(255) collate utf8_unicode_ci default NULL,\n                  `comment` text collate utf8_unicode_ci,\n                  PRIMARY KEY  (`id`),\n                  KEY `name` (`name`)\n               ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->query($query) or die($DB->error());
         $taxes = new self();
         foreach (array('20', '5.5', '19.6') as $tax) {
             $taxes->add(array('name' => $tax));
         }
     } else {
         //Update
         $migration->displayMessage("Migrating {$table}");
         //1.2.0
         $migration->renameTable("glpi_dropdown_plugin_order_taxes", $table);
         $migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
         $migration->changeField($table, "name", "name", "varchar(255) collate utf8_unicode_ci default NULL");
         $migration->changeField($table, "comments", "comment", "text collate utf8_unicode_ci");
         $migration->migrationOneTable($table);
         //Remplace , by . in taxes
         foreach ($DB->request("SELECT `name` FROM `{$table}`") as $data) {
             if (strpos($data["name"], ',')) {
                 $name = str_replace(',', '.', $data["name"]);
                 $query = "UPDATE `{$table}`\n                         SET `name` = '" . $name . "'\n                         WHERE `name`= '" . $data["name"] . "'";
                 $DB->query($query) or die($DB->error());
             }
         }
     }
 }
开发者ID:equinoxefr,项目名称:order,代码行数:32,代码来源:ordertax.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

 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         `plugin_itilcategorygroups_categories_id` INT(11)    NOT NULL DEFAULT '0',\n         `level`                                   TINYINT(1) NOT NULL DEFAULT '0',\n         `itilcategories_id`                       INT(11)    NOT NULL DEFAULT '0',\n         `groups_id`                               INT(11)    NOT NULL DEFAULT '0',\n         PRIMARY KEY (`id`),\n         UNIQUE KEY `group_lvl_unicity` (plugin_itilcategorygroups_categories_id, level, groups_id),\n         KEY `plugin_itilcategorygroups_categories_id` (`plugin_itilcategorygroups_categories_id`),\n         KEY `level`                                   (`level`),\n         KEY `itilcategories_id`                       (`itilcategories_id`),\n         KEY `groups_id`                               (`groups_id`)\n         ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;";
         $DB->query($query);
     }
     $parent_table = "glpi_plugin_itilcategorygroups_categories";
     //we must migrate groups datas in sub table
     if (FieldExists($parent_table, 'groups_id_levelone')) {
         $all_lvl = $cat_groups = array();
         //foreach old levels
         foreach (array(1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four') as $lvl_num => $lvl_str) {
             $query = "SELECT id, itilcategories_id, groups_id_level{$lvl_str} FROM {$parent_table}";
             $res = $DB->query($query);
             while ($data = $DB->fetch_assoc($res)) {
                 //specific case (all group of this lvl), store it for further treatment
                 if ($data["groups_id_level{$lvl_str}"] == -1) {
                     $all_lvl[$data['itilcategories_id']][$lvl_num] = $lvl_str;
                 }
                 if ($data["groups_id_level{$lvl_str}"] > 0) {
                     $cat_groups[] = array('plugin_itilcategorygroups_categories_id' => $data['id'], 'level' => $lvl_num, 'itilcategories_id' => $data['itilcategories_id'], 'groups_id' => $data["groups_id_level{$lvl_str}"]);
                 }
             }
             //insert "all groups for this lvl'
             foreach ($all_lvl as $itilcategories_id => $lvl) {
                 foreach ($lvl as $lvl_num => $lvl_str) {
                     $DB->query("UPDATE {$parent_table} SET view_all_lvl{$lvl_num} = 1\n                              WHERE itilcategories_id = {$itilcategories_id}");
                 }
             }
             //insert groups in sub table
             foreach ($cat_groups as $cat_groups_data) {
                 $DB->query("REPLACE INTO glpi_plugin_itilcategorygroups_categories_groups\n                              (plugin_itilcategorygroups_categories_id,\n                               level,\n                               itilcategories_id,\n                               groups_id)\n                           VALUES (\n                              " . $cat_groups_data['plugin_itilcategorygroups_categories_id'] . ",\n                              " . $cat_groups_data['level'] . ",\n                              " . $cat_groups_data['itilcategories_id'] . ",\n                              " . $cat_groups_data['groups_id'] . "\n                           )");
             }
         }
         //drop migrated fields
         $migration->dropField($parent_table, "groups_id_levelone");
         $migration->dropField($parent_table, "groups_id_leveltwo");
         $migration->dropField($parent_table, "groups_id_levelthree");
         $migration->dropField($parent_table, "groups_id_levelfour");
         $migration->migrationOneTable($parent_table);
     }
     return true;
 }
开发者ID:pluginsGLPI,项目名称:itilcategorygroups,代码行数:45,代码来源:category_group.class.php

示例7: install

 static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     if (!TableExists($table) && !TableExists("glpi_dropdown_plugin_order_payment")) {
         $migration->displayMessage("Installing {$table}");
         $query = "CREATE TABLE `glpi_plugin_order_orderpayments` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `name` varchar(255) collate utf8_unicode_ci default NULL,\n                  `comment` text collate utf8_unicode_ci,\n                  PRIMARY KEY  (`id`),\n                  KEY `name` (`name`)\n               ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->query($query) or die($DB->error());
     } else {
         $migration->displayMessage("Upgrading {$table}");
         //1.2.0
         $migration->renameTable("glpi_dropdown_plugin_order_payment", $table);
         $migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
         $migration->changeField($table, "name", "name", "varchar(255) collate utf8_unicode_ci default NULL");
         $migration->changeField($table, "comments", "comment", "text collate utf8_unicode_ci");
         $migration->migrationOneTable($table);
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:18,代码来源:orderpayment.class.php

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

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

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

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

示例12: install

 public static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     $config = new self();
     //This class is available since version 1.3.0
     if (!TableExists($table) && !TableExists("glpi_plugin_order_config")) {
         $migration->displayMessage("Installing {$table}");
         //Install
         $query = "CREATE TABLE `{$table}` (\n                        `id` int(11) NOT NULL auto_increment,\n                        `use_validation` tinyint(1) NOT NULL default '0',\n                        `use_supplier_satisfaction` tinyint(1) NOT NULL default '0',\n                        `use_supplier_informations` tinyint(1) NOT NULL default '0',\n                        `use_supplier_infos` tinyint(1) NOT NULL default '1',\n                        `generate_order_pdf` tinyint(1) NOT NULL default '0',\n                        `copy_documents` tinyint(1) NOT NULL default '0',\n                        `default_taxes` int(11) NOT NULL default '0',\n                        `generate_assets` int(11) NOT NULL default '0',\n                        `generated_name` varchar(255) collate utf8_unicode_ci default NULL,\n                        `generated_serial` varchar(255) collate utf8_unicode_ci default NULL,\n                        `generated_otherserial` varchar(255) collate utf8_unicode_ci default NULL,\n                        `default_asset_states_id` int(11) NOT NULL default '0',\n                        `tickettemplates_id_delivery` int(11) NOT NULL default '0',\n                        `order_status_draft` int(11) NOT NULL default '0',\n                        `order_status_waiting_approval` int(11) NOT NULL default '0',\n                        `order_status_approved` int(11) NOT NULL default '0',\n                        `order_status_partially_delivred` int(11) NOT NULL default '0',\n                        `order_status_completly_delivered` int(11) NOT NULL default '0',\n                        `order_status_canceled` int(11) NOT NULL default '0',\n                        `order_status_paid` int(11) NOT NULL default '0',\n                        `shoudbedelivered_color` char(20) collate utf8_unicode_ci default '#ff5555',\n                        `documentcategories_id` int(11) NOT NULL default '0',\n                        `groups_id_author` int(11) NOT NULL default '0',\n                        `groups_id_recipient` int(11) NOT NULL default '0',\n                        `users_id_recipient` int(11) NOT NULL default '0',\n                        `add_location` tinyint(1) NOT NULL default '0',\n                        `add_bill_details` tinyint(1) NOT NULL default '0',\n                        `hide_inactive_budgets` tinyint(1) NOT NULL default '0',\n                        `rename_documents` tinyint(1) NOT NULL default '0',\n                        `transmit_budget_change` 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());
         $tobefilled = "TOBEFILLED";
         $tmp = array('id' => 1, 'use_validation' => 0, 'default_taxes' => 0, 'generate_assets' => 0, 'generated_name' => $tobefilled, 'generated_serial' => $tobefilled, 'generated_otherserial' => $tobefilled, 'default_asset_states_id' => 0, 'generated_title' => $tobefilled, 'generated_content' => $tobefilled, 'default_ticketcategories_id' => 0, 'shoudbedelivered_color' => '#ff5555');
         $config->add($tmp);
     } else {
         //Upgrade
         $migration->displayMessage("Upgrading {$table}");
         //1.2.0
         $migration->renameTable("glpi_plugin_order_config", $table);
         if (!countElementsInTable("glpi_plugin_order_configs")) {
             $query = "INSERT INTO `glpi_plugin_order_configs`(`id`,`use_validation`,`default_taxes`) VALUES (1,0,0);";
             $DB->query($query) or die($DB->error());
         }
         $migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
         //1.3.0
         $migration->addField($table, "generate_assets", "tinyint(1) NOT NULL default '0'");
         $migration->addField($table, "generated_name", "varchar(255) collate utf8_unicode_ci default NULL");
         $migration->addField($table, "generated_serial", "varchar(255) collate utf8_unicode_ci default NULL");
         $migration->addField($table, "generated_otherserial", "varchar(255) collate utf8_unicode_ci default NULL");
         $migration->addField($table, "default_asset_entities_id", "int(11) NOT NULL default '0'");
         $migration->addField($table, "default_asset_states_id", "int(11) NOT NULL default '0'");
         $migration->addField($table, "generated_title", "varchar(255) collate utf8_unicode_ci default NULL");
         $migration->addField($table, "generated_content", "text collate utf8_unicode_ci");
         $migration->addField($table, "default_ticketcategories_id", "int(11) NOT NULL default '0'");
         $migration->addField($table, "use_supplier_satisfaction", "tinyint(1) NOT NULL default '0'");
         $migration->addField($table, "generate_order_pdf", "tinyint(1) NOT NULL default '0'");
         $migration->addField($table, "use_supplier_informations", "tinyint(1) NOT NULL default '1'");
         $migration->addField($table, "shoudbedelivered_color", "char(20) collate utf8_unicode_ci default '#ff5555'");
         $migration->addField($table, "copy_documents", "tinyint(1) NOT NULL DEFAULT '0'");
         $migration->addField($table, "documentcategories_id", "integer");
         $migration->addField($table, "groups_id_author", "integer");
         $migration->addField($table, "groups_id_recipient", "integer");
         $migration->addField($table, "users_id_recipient", "integer");
         $migration->changeField($table, "default_ticketcategories_id", "default_itilcategories_id", "integer");
         //1.9.0
         $migration->addField($table, "add_location", "TINYINT(1) NOT NULL DEFAULT '0'");
         $migration->addField($table, "add_bill_details", "TINYINT(1) NOT NULL DEFAULT '0'");
         $config = new self();
         $config->getFromDB(1);
         $templateID = false;
         $migration->addField($table, "tickettemplates_id_delivery", 'integer');
         $migration->migrationOneTable($table);
         $migration->dropField($table, "generated_title");
         $migration->dropField($table, "generated_content");
         $migration->dropField($table, "default_itilcategories_id");
         $migration->addField($table, "hide_inactive_budgets", "bool");
         $migration->addField($table, "rename_documents", "bool");
         //0.85+1.2
         $migration->addField($table, "transmit_budget_change", "bool");
         $migration->migrationOneTable($table);
         if ($templateID) {
             $config->update(array('id' => 1, 'tickettemplates_id_delivery' => $templateID));
         }
     }
     $migration->displayMessage("Add default order state workflow");
     $new_states = array('order_status_draft' => 1, 'order_status_waiting_approval' => 2, 'order_status_approved' => 3, 'order_status_partially_delivred' => 4, 'order_status_completly_delivered' => 5, 'order_status_canceled' => 6, 'order_status_paid' => 7);
     foreach ($new_states as $field => $value) {
         $migration->addField($table, $field, "int(11) NOT NULL default '0'");
     }
     $migration->migrationOneTable($table);
     $new_states['id'] = 1;
     $config->update($new_states);
 }
开发者ID:pluginsGLPI,项目名称:order,代码行数:73,代码来源:config.class.php

示例13: install

 static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     if (TableExists("glpi_plugin_itilcategorygroups_categories_groups") && FieldExists("glpi_plugin_itilcategorygroups_categories_groups", 'is_active')) {
         $migration->renameTable("glpi_plugin_itilcategorygroups_categories_groups", $table);
     }
     if (!TableExists($table)) {
         $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n         `id` INT(11) NOT NULL AUTO_INCREMENT,\n         `is_active` TINYINT(1) NOT NULL DEFAULT '0',\n         `name` VARCHAR(255) COLLATE utf8_unicode_ci DEFAULT '',\n         `comment` TEXT COLLATE utf8_unicode_ci,\n         `date_mod` DATE default NULL,\n         `itilcategories_id` INT(11) NOT NULL DEFAULT '0',\n         `view_all_lvl1` TINYINT(1) NOT NULL DEFAULT '0',\n         `view_all_lvl2` TINYINT(1) NOT NULL DEFAULT '0',\n         `view_all_lvl3` TINYINT(1) NOT NULL DEFAULT '0',\n         `view_all_lvl4` TINYINT(1) NOT NULL DEFAULT '0',\n         `entities_id` INT(11) NOT NULL DEFAULT '0',\n         `is_recursive` TINYINT(1) NOT NULL DEFAULT '1',\n         `is_incident` TINYINT(1) NOT NULL DEFAULT '1',\n         `is_request` TINYINT(1) NOT NULL DEFAULT '1',\n         PRIMARY KEY (`id`),\n         KEY `entities_id` (`entities_id`),\n         KEY `itilcategories_id` (`itilcategories_id`),\n         KEY `is_incident` (`is_incident`),\n         KEY `is_request` (`is_request`),\n         KEY `is_recursive` (`is_recursive`),\n         KEY date_mod (date_mod)\n         ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;";
         $DB->query($query);
     }
     if (!FieldExists($table, 'view_all_lvl1')) {
         $migration->addField($table, 'view_all_lvl1', "TINYINT(1) NOT NULL DEFAULT '0'", array('after' => 'itilcategories_id'));
         $migration->addField($table, 'view_all_lvl2', "TINYINT(1) NOT NULL DEFAULT '0'", array('after' => 'itilcategories_id'));
         $migration->addField($table, 'view_all_lvl3', "TINYINT(1) NOT NULL DEFAULT '0'", array('after' => 'itilcategories_id'));
         $migration->addField($table, 'view_all_lvl4', "TINYINT(1) NOT NULL DEFAULT '0'", array('after' => 'itilcategories_id'));
         $migration->migrationOneTable($table);
     }
     return true;
 }
开发者ID:erchbox,项目名称:itilcategorygroups,代码行数:20,代码来源:category.class.php

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

示例15: install

 public static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     if (!TableExists($table)) {
         if (!TableExists("glpi_plugin_order_suppliers")) {
             $migration->displayMessage("Installing {$table}");
             //install
             $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_orders_suppliers` (\n                     `id` int(11) NOT NULL auto_increment,\n                     `entities_id` int(11) NOT NULL default '0',\n                     `is_recursive` tinyint(1) NOT NULL default '0',\n                     `plugin_order_orders_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orders (id)',\n                     `suppliers_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)',\n                     `num_quote` varchar(255) collate utf8_unicode_ci default NULL,\n                     `num_order` varchar(255) collate utf8_unicode_ci default NULL,\n                     `num_bill` varchar(255) collate utf8_unicode_ci default NULL,\n                     PRIMARY KEY  (`id`),\n                     KEY `plugin_order_orders_id` (`plugin_order_orders_id`),\n                     KEY `entities_id` (`entities_id`),\n                     KEY `suppliers_id` (`suppliers_id`)\n                  ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
             $DB->query($query) or die($DB->error());
         } else {
             //Upgrade
             $migration->displayMessage("Upgrading {$table}");
             //1.2.0
             $migration->renameTable("glpi_plugin_order_suppliers", $table);
             $migration->addField($table, "entities_id", "int(11) NOT NULL default '0'");
             $migration->addField($table, "is_recursive", "tinyint(1) NOT NULL default '0'");
             $migration->addField($table, "suppliers_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_suppliers (id)'");
             $migration->changeField($table, "ID", "id", "int(11) NOT NULL auto_increment");
             $migration->changeField($table, "FK_order", "plugin_order_orders_id", "int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_plugin_order_orders (id)'");
             $migration->changeField($table, "numquote", "num_quote", "varchar(255) collate utf8_unicode_ci default NULL");
             $migration->changeField($table, "numbill", "num_bill", "varchar(255) collate utf8_unicode_ci default NULL");
             $migration->changeField($table, "numorder", "num_order", "varchar(255) collate utf8_unicode_ci default NULL");
             $migration->addKey($table, "plugin_order_orders_id");
             $migration->addKey($table, "suppliers_id");
             $migration->migrationOneTable($table);
             Plugin::migrateItemType(array(3154 => 'PluginOrderOrder_Supplier'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets"), array());
             //1.5.0
             $query = "SELECT `suppliers_id`, `entities_id`,`is_recursive`,`id`\n                      FROM `glpi_plugin_order_orders` ";
             foreach ($DB->request($query) as $data) {
                 $query = "UPDATE `glpi_plugin_order_orders_suppliers` SET\n                           `suppliers_id` = '{$data["suppliers_id"]}'\n                         WHERE `plugin_order_orders_id` = '{$data["id"]}' ";
                 $DB->query($query) or die($DB->error());
                 $query = "UPDATE `glpi_plugin_order_orders_suppliers` SET\n                           `entities_id` = '{$data["entities_id"]}',\n                           `is_recursive` = '{$data["is_recursive"]}'\n                         WHERE `plugin_order_orders_id` = '{$data["id"]}' ";
                 $DB->query($query) or die($DB->error());
             }
         }
     }
 }
开发者ID:equinoxefr,项目名称:order,代码行数:38,代码来源:order_supplier.class.php


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