Migration::dropField PHP Method

dropField() public method

Drop field for migration
public dropField ( $table, $field )
$table string
$field string field to drop
    function dropField($table, $field)
    {
        if (FieldExists($table, $field, false)) {
            $this->change[$table][] = "DROP `{$field}`";
        }
    }

Usage Example

Ejemplo n.º 1
0
 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;
 }
All Usage Examples Of Migration::dropField