Jelajahi Sumber

Fix Maj SQL

stany.ferer 1 tahun lalu
induk
melakukan
5f38d19bab
1 mengubah file dengan 22 tambahan dan 12 penghapusan
  1. 22 12
      core/class/maj.class.php

+ 22 - 12
core/class/maj.class.php

@@ -67,18 +67,6 @@ class maj {
         backup::create();
         file::cleanFilesByOrder(DIR_BACKUP, BACKUP_LIMIT);
 
-/*
-        include_once(DIR_MAJ . "sql/maj.php");
-        self::printSeparateur();
-        if(goSql() == TRUE){
-            self::print("Maj SQL réalisée", self::$colorLineGrey);
-            self::printSeparateur();
-            $gitReturn = self::bashMaj();
-        } else {
-            self::print("ERROR : Maj SQL", self::$colorLineRed);
-        }
-*/
-
         if(self::bashMaj() == FALSE){
             self::printSeparateur();
             self::print("ERROR : Repo GIT [" . MAJ_TARGET . " - " . git::getCommitHash(MAJ_TARGET) . "]", self::$colorLineRed);
@@ -100,6 +88,28 @@ class maj {
             self::print("Mise à jour du repo GIT [" . MAJ_TARGET . " - " . git::getCommitHash(MAJ_TARGET) . "] effectué", self::$colorLineGrey);
         }
 
+        include_once(DIR_MAJ . "sql/maj.php");
+        if(goSql() == FALSE){
+            self::printSeparateur();
+            self::print("ERROR : Maj SQL", self::$colorLineRed);
+            self::printSeparateur();
+            self::print(">> ROLLBACK : Restauration des données", self::$colorLineOrange);
+            backup::restore(DIR_BACKUP . backup::last());
+
+            alert::recError("ERROR : Maj SQL");
+
+            historique::recRef("/parametres.html");
+            historique::add(array(
+                "idType" => historique::getIdRef("ERROR"),
+                "idUser" => session::getId(),
+                "idPage" => historique::getIdRef("/parametres.html"),
+                "log" => "ERROR : Maj SQL"
+            ));
+        } else {
+            self::printSeparateur();
+            self::print("Maj SQL réalisée", self::$colorLineGrey);
+        }
+
         self::printSeparateur();
         self::print(">> Réinitialisation des JSON", self::$colorLineGrey);
         json::create("salaries");