You are not logged in.
Hi,
I wrote a procedure upgrade and scripts for my work which allow to upgrade Custom Fileds 1.1.0 to 1.4.0, these scripts were tested with GLPI 0.72.2 to 0.83.4, if the 1.1. * other plugins works the same way, this script should be works with, if somebody could confirm or not. if not this script is easily adaptable.
the different step to use this scripts:
scripts : https://docs.google.com/open?id=0B5RlYZ … zdRTldYMnc
- Make GLPI database complete dump
- Deactivate custom fields plugin
- Execute custom.php
2 files should be created, one with the "glpi_plugin_customfield*" tables (glpi_plugin_customfields_1.4.sql), and one other with the "glpi_dropdown_plugin_customfields*" tables (glpi_dropdown_plugin_customfields.sql) from GLPI database. all tables begin like "glpi_plugin_customfield" will be deleted after dump.
- Uninstall and delete the custom fields plugin.
- Download the latest custom fields version 1.4.0
- Install and activate custom fields 1.4.0
- Import glpi_plugin_customfields_1.4.sql and glpi_dropdown_plugin_customfields.sql to the database
- Execute migration.php to upgrade data
Offline
Hello,
currently i am testing updating custom fields from V1.1.0 to V1.4,0 in my test environment. I will try out your solution tomorrow in my office. After testing i give you a feedback here.
Greetings
bmw328ii
Offline
Hi,
how to run the php files?
Offline
Hi,
you can run the php script like that:
"php custom.php"
be sure that php5 is installed and don't forget to modify include.php with your mysql credentials.
Offline
Hi,
i have changed credentials in include.php.
When I run the custom.php file i get following output:
C:\Temp\Export>php custom.php
<?
include "include.php";
$bdd_glpi = new class_bdd("glpi");
$tab_test= $bdd_glpi->resArray("show tables like 'glpi_plugin_customfields_networking'");
if (count($tab_test) == 1){$bdd_glpi->exeReq("RENAME TABLE glpi_plugin_customfields_networking TO glpi_plugin_customfields_networkequipments");}
$tab_test= $bdd_glpi->resArray("show tables like 'glpi_plugin_customfields_software'");
if (count($tab_test) == 1){$bdd_glpi->exeReq("RENAME TABLE glpi_plugin_customfields_software TO glpi_plugin_customfields_softwares");}
$tab_test= $bdd_glpi->resArray("show tables like 'glpi_plugin_customfields_user'");
if (count($tab_test) == 1){$bdd_glpi->exeReq("RENAME TABLE glpi_plugin_customfields_user TO glpi_plugin_customfields_users");}
$tab_tables= $bdd_glpi->resArray("show tables like 'glpi_plugin_customfield%'");
$tab_tables_drop= $bdd_glpi->resArray("show tables like 'glpi_dropdown_plugin_customfields%'");
// print_r($tab_tables);exit;
// print count($tab_tables);exit;
// Modification de deux tables du plugin pour preparer la migration des donn├®es de GLPI0.72 ├á 0.83 / custom filed 1.1.0 ├á 1.4.0
// $bdd_glpi->exeReq("ALTER TABLE glpi_plugin_customfields_fields CHANGE ID id int(11);");
$tab_test= $bdd_glpi->resArray("show tables like 'glpi_plugin_customfields_fields'");
if (count($tab_test) ==1){
$bdd_glpi->exeReq("ALTER TABLE `glpi_plugin_customfields_fields` CHANGE device_type itemtype varchar(100);");
$bdd_glpi->exeReq("ALTER TABLE `glpi_plugin_customfields_fields` DROP hidden;");
$bdd_glpi->exeReq("UPDATE `glpi_plugin_customfields_fields` SET itemtype = 'Computer' WHERE itemtype = 1;");
$bdd_glpi->exeReq("UPDATE `glpi_plugin_customfields_fields` SET itemtype = 'ComputerDisk' WHERE itemtype = 41;");
$bdd_glpi->exeReq("UPDATE `glpi_plugin_customfields_fields` SET itemtype = 'Monitor' WHERE itemtype = 4;");
$bdd_glpi->exeReq("UPDATE `glpi_plugin_customfields_fields` SET itemtype = 'Software' WHERE itemtype = 6;");
$bdd_glpi->exeReq("UPDATE `glpi_plugin_customfields_fields` SET itemtype = 'NetworkEquipment' WHERE itemtype = 2;");
$bdd_glpi->exeReq("UPDATE `glpi_plugin_customfields_fields` SET itemtype = 'Peripheral' WHERE itemtype = 5;");
$bdd_glpi->exeReq("UPDATE `glpi_plugin_customfields_fields` SET itemtype = 'Printer' WHERE itemtype = 3;");
$bdd_glpi->exeReq("UPDATE `glpi_plugin_customfields_fields` SET itemtype = 'Phone' WHERE itemtype = 23;");
$bdd_glpi->exeReq("UPDATE `glpi_plugin_customfields_fields` SET itemtype = 'User' WHERE itemtype = 15;");
$bdd_glpi->exeReq("ALTER TABLE glpi_plugin_customfields_fields ADD `required` smallint(6) NOT NULL default '0';");
$bdd_glpi->exeReq("ALTER TABLE glpi_plugin_customfields_fields ADD `entities` varchar(255) collate utf8_unicode_ci NOT NULL default '*
';");
$bdd_glpi->exeReq("ALTER TABLE glpi_plugin_customfields_fields ADD `restricted` smallint(6) NOT NULL default '0';");
}
$tab_test= $bdd_glpi->resArray("show tables like 'glpi_plugin_customfields_dropdowns'");
if (count($tab_test) ==1){
$bdd_glpi->exeReq("ALTER TABLE `glpi_plugin_customfields_dropdowns` CHANGE label name varchar(70);");
}
// exit;
for ($i = 0; $i < count($tab_tables_drop); $i++) {
$table_drop=$tab_tables_drop[$i][0];
$exp=exec("mysqldump --add-locks --quote-names -h$APPLI_GLPI_HOST -u$APPLI_GLPI_LOGIN -p$APPLI_GLPI_MDP $APPLI_GLPI_BDD $table_drop >
> $EXPORTDATA");
echo $exp;
echo "$EXPORT - $table_drop ";
$result= shell_exec("tail -1 $EXPORTDATA");
echo $result;
}
//Export et suppression des tables du plugin customfields
for ($i = 0; $i < count($tab_tables); $i++) {
$table=$tab_tables[$i][0];
// print $table."\n";
$bdd_glpi->exeReq("ALTER TABLE $table CHANGE ID id int(11);");
$exp=exec("mysqldump --add-locks --quote-names -h$APPLI_GLPI_HOST -u$APPLI_GLPI_LOGIN -p$APPLI_GLPI_MDP $APPLI_GLPI_BDD $table >> $EX
PORT");
echo $exp;
echo "$EXPORT - $table ";
$result= shell_exec("tail -1 $EXPORT");
echo $result;
//si l'export est bien terminer, supprimer la table
$test=preg_match('/Dump completed/',$result);
// echo $test;
$test=1;
if ($test == 1){
$del=$bdd_glpi->exeReq("drop table $table;");
// echo($bdd_glpi->res_req);
if ($bdd_glpi->res_req == 1){
echo "$table deleted \n";
}
else{
echo "erreur suppression $table \n\n";
}
}
}
// $tab_tables= $bdd_glpi->resArray("show tables like 'glpi_plugin_customfield%'");
// for ($i = 0; $i < count($tab_tables); $i++) {
// $table=$tab_tables[$i][0];
// $bdd_glpi->exeReq("drop table $table;");
// }
?>
C:\Temp\Export>
Where is the error? It´s only the output of the script?
Offline
if you run the script on windows, you have to add php binary path in the widows path or move to the binary installation with cd command before execute it.
Offline
Hi,
yes i know this. It have done it month ago. When I run the include script, nothing is displayed, the prompt appears blinking again. It seems that the script ran without error, but the two sql files are not generated.
When I run the custom.php with php.exe always the entire script is displayed completly in my cmd window. I don´t know where the error is....
Offline
i wrote this script on windows but i run it in linux, i didn't try to execute it from windows but i think it should be work, f you can try to run it from Linux. i don't see want wrong when you tried to run it, it seem the script is not execute.
Offline