New: Enhance Dolibarr migration process to include migration script of

external modules.
This commit is contained in:
Laurent Destailleur 2013-03-13 11:06:28 +01:00
parent 9527174300
commit 60930d9e74
3 changed files with 40 additions and 8 deletions

View File

@ -45,6 +45,8 @@ For developers:
- New: dol_syslog method accept a suffix to use different log files for log.
- New: Type of fields are received by export format handlers
- New: when adding an action, we can define a free code to tag it for a specific need.
- New: Enhance Dolibarr migration process to include migration script of external
modules.
WARNING: If you used external modules, some of them may need to be upgraded due to:
- fields of classes were renamed to be normalized (nom, prenom, cp, ville, adresse were

View File

@ -250,7 +250,7 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker
$newsql=preg_replace('/__ENTITY__/i',(!empty($entity)?$entity:$conf->entity),$sql);
// Ajout trace sur requete (eventuellement a commenter si beaucoup de requetes)
if (! $silent) print '<tr><td valign="top">'.$langs->trans("Request").' '.($i+1)." sql='".$newsql."'</td></tr>\n";
if (! $silent) print '<tr><td valign="top">'.$langs->trans("Request").' '.($i+1)." sql='".dol_htmlentities($newsql,ENT_NOQUOTES)."'</td></tr>\n";
dol_syslog('Admin.lib::run_sql Request '.($i+1).' sql='.$newsql, LOG_DEBUG);
// Replace for encrypt data
@ -1153,10 +1153,10 @@ function showModulesExludedForExternal($modules)
$moduleconst=$module->const_name;
$modulename=strtolower($module->name);
//print 'modulename='.$modulename;
//if (empty($conf->global->$moduleconst)) continue;
if (! in_array($modulename,$listofmodules)) continue;
if ($i > 0) $text.=', ';
else $text.=' ';
$i++;

View File

@ -326,7 +326,7 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
$dir = "mysql/migration/"; // We use mysql migration scripts whatever is database driver
if (! empty($versionmodule)) $dir=dol_buildpath('/'.$versionmodule.'/sql/',0);
// For minor version
// Clean last part to exclude minor version x.y.z -> x.y
$newversionfrom=preg_replace('/(\.[0-9]+)$/i','.0',$versionfrom);
$newversionto=preg_replace('/(\.[0-9]+)$/i','.0',$versionto);
@ -368,13 +368,43 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
// Loop on each migrate files
foreach($filelist as $file)
{
print '<tr><td nowrap>';
print $langs->trans("ChoosedMigrateScript").'</td><td align="right">'.$file.'</td></tr>'."\n";
$name = substr($file, 0, dol_strlen($file) - 4);
print '<tr><td colspan="2"><hr></td></tr>';
print '<tr><td nowrap>'.$langs->trans("ChoosedMigrateScript").'</td><td align="right">'.$file.'</td></tr>'."\n";
// Run sql script
$ok=run_sql($dir.$file, 0, '', 1);
// Scan if there is migration scripts for modules htdocs/module/sql or htdocs/custom/module/sql
$modulesfile = array();
foreach ($conf->file->dol_document_root as $type => $dirroot)
{
$handlemodule=@opendir($dirroot);
if (is_resource($handlemodule))
{
while (($filemodule = readdir($handlemodule))!==false)
{
if (is_dir($dirroot.'/'.$filemodule.'/sql'))
{
//print "Scan for ".$dirroot . '/' . $filemodule . '/sql/'.$file;
if (is_file($dirroot . '/' . $filemodule . '/sql/'.$file))
{
$modulesfile[$dirroot . '/' . $filemodule . '/sql/'.$file] = '/' . $filemodule . '/sql/'.$file;
}
}
}
closedir($handlemodule);
}
}
foreach ($modulesfile as $modulefilelong => $modulefileshort)
{
print '<tr><td colspan="2"><hr></td></tr>';
print '<tr><td nowrap>'.$langs->trans("ChoosedMigrateScript").' (external modules)</td><td align="right">'.$modulefileshort.'</td></tr>'."\n";
// Run sql script
$okmodule=run_sql($modulefilelong, 0, '', 1); // Note: Result of migration of external module should not decide if we continue migration of Dolibarr or not.
}
}
}