diff --git a/html/admin/setup.php b/html/admin/setup.php index ed89afbf2..806984445 100644 --- a/html/admin/setup.php +++ b/html/admin/setup.php @@ -41,6 +41,22 @@ include_once('postgres.php'); include_once('debug.php'); include_once('ac_common.php'); include_once('variable.php'); +/* function GetVersion + ************************************************** + * Purpose : Get version of a database + * + * parm : + * - $p_cn database connection + * gen : + * - none + * return: + * none + */ +function GetVersion($p_cn) { + $Res=ExecSql($p_cn,"select val from version"); + $a=pg_fetch_array($Res,0); + return $a['val']; +} /* function ExecuteScript ************************************************** * Purpose : Execute a sql script @@ -113,7 +129,13 @@ if ($cn == false ) { puis la base de données par défaut de phpcompta.
"; exit(); } - +?> + + +if ( ! isset($_POST['go']) ) + exit(); // Check if account_repository exists $account=CountSql($cn, "select * from pg_database where datname='account_repository'"); @@ -166,8 +188,8 @@ $MaxDossier=pg_NumRows($Res); for ($e=0;$e < $MaxDossier;$e++) { $db_row=pg_fetch_array($Res,$e); echo "Patching ".$db_row['dos_name']; - if ( GetVersion($db_row['dos_id']) == 3 ) { - $db=DbConnect($db_row['dos_id'],'dossier'); + $db=DbConnect($db_row['dos_id'],'dossier'); + if ( GetVersion($db) == 3 ) { ExecuteScript($db,'sql/patch/upgrade4.sql'); $sql="select jrn_def_id from jrn_def "; diff --git a/html/admin/sql/patch/upgrade4.sql b/html/admin/sql/patch/upgrade4.sql index 24e7efbb5..d6dacace2 100644 --- a/html/admin/sql/patch/upgrade4.sql +++ b/html/admin/sql/patch/upgrade4.sql @@ -22,10 +22,11 @@ comment on table parm_periode is 'Periode definition'; comment on table stock_goods is 'About the goods'; comment on table tmp_pcmn is 'Plan comptable minimum normalisé'; comment on table tva_rate is 'Rate of vat'; -create index x_jr_grpt_id on jrn (jr_grpt_id); -create index x_j_grpt on jrnx(j_grpt); -create index x_poste on jrnx(j_poste );delete from jrn_action where ja_name='Impression'; +-- create index x_jr_grpt_id on jrn (jr_grpt_id); +-- create index x_j_grpt on jrnx(j_grpt); +create index x_poste on jrnx(j_poste ); +delete from jrn_action where ja_name='Impression'; delete from fiche where f_id not in (select f_id from jnt_fic_att_value); alter table jrn add j_pj int4; alter table jrn add jr_opid int4; -upgrade version set val=4; +update version set val=4;