NEW A module can embed a sql script run at each Dolibarr upgrade

This commit is contained in:
Laurent Destailleur 2022-02-23 12:55:15 +01:00
parent e119ea0524
commit 88f1ae9c13
3 changed files with 9 additions and 13 deletions

View File

@ -355,7 +355,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Scan if there is migration scripts that depends of Dolibarr version
// for modules htdocs/module/sql or htdocs/custom/module/sql (files called "dolibarr_x.y.z-a.b.c.sql")
// for modules htdocs/module/sql or htdocs/custom/module/sql (files called "dolibarr_x.y.z-a.b.c.sql" or "dolibarr_always.sql")
$modulesfile = array();
foreach ($conf->file->dol_document_root as $type => $dirroot) {
$handlemodule = @opendir($dirroot); // $dirroot may be '..'
@ -366,6 +366,9 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
if (is_file($dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file)) {
$modulesfile[$dirroot.'/'.$filemodule.'/sql/dolibarr_'.$file] = '/'.$filemodule.'/sql/dolibarr_'.$file;
}
if (is_file($dirroot.'/'.$filemodule.'/sql/dolibarr_allversions.sql')) {
$modulesfile[$dirroot.'/'.$filemodule.'/sql/dolibarr_allversions.sql'] = '/'.$filemodule.'/sql/dolibarr_allversions.sql';
}
}
}
closedir($handlemodule);

View File

@ -0,0 +1,3 @@
--
-- Script run when an upgrade of Dolibarr is done. Whatever is the Dolibarr version.
--

View File

@ -1,14 +1,4 @@
-- Copyright (C) ---Put here your own copyright and developer email---
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
-- Script run to make a migration of module version x.x.x to module version y.y.y
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.