mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 01:58:47 +02:00
N°1001 setup : log all modifications done on the DB in a SQL file (/log/setup-queries-YYYY-MM-DD_HH-mm.sql)
SVN:trunk[5445]
This commit is contained in:
@@ -99,6 +99,7 @@ class RunTimeEnvironment
|
||||
public function LogQueryCallback($sQuery, $fDuration)
|
||||
{
|
||||
$this->log_info(sprintf('%.3fs - query: %s ', $fDuration, $sQuery));
|
||||
$this->log_db_query($sQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -917,6 +918,25 @@ class RunTimeEnvironment
|
||||
{
|
||||
SetupPage::log_ok($sText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes queries run by the setup in a SQL file
|
||||
*
|
||||
* @param string $sQuery
|
||||
*
|
||||
* @since 2.5 #1001 utf8mb4 switch
|
||||
* @uses \SetupUtils::GetSetupQueriesFilePath()
|
||||
*/
|
||||
protected function log_db_query($sQuery)
|
||||
{
|
||||
$sSetupQueriesFilePath = SetupUtils::GetSetupQueriesFilePath();
|
||||
$hSetupQueriesFile = @fopen($sSetupQueriesFilePath, 'a');
|
||||
if ($hSetupQueriesFile !== false)
|
||||
{
|
||||
fwrite($hSetupQueriesFile, "$sQuery\n");
|
||||
fclose($hSetupQueriesFile);
|
||||
}
|
||||
}
|
||||
|
||||
public function GetCurrentDataModelVersion()
|
||||
{
|
||||
|
||||
@@ -1821,6 +1821,14 @@ EOF
|
||||
}
|
||||
return $aLicenses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string path to the log file where the create and/or alter queries are written
|
||||
*/
|
||||
static public function GetSetupQueriesFilePath()
|
||||
{
|
||||
return APPROOT.'log/setup-queries-'.strftime('%Y-%m-%d_%H_%M').'.sql';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user