Hi, I was wondering if anyone had any advice on my current EE database versioning routine, I’m worried I might end up causing myself a lot of headaches with this so I thought I’d better share and get some feedback.
In order to keep my local DB and remote DB as close to the same as possible (at least with the important stuff), I’ve had to hack the mysql driver in CI specifically the _execute method on line 178 I’ve add $this->_log_query_vcs($sql); The idea is that I log any important changes to the DB as they happen local and remote and diff the file, then import the changes.
Here’s my _log_query_vcs method:
/**
* Hack to log queries to file fo version control
*
* @access private
* @param string an SQL query
* @return void
*/
function _log_query_vcs($sql)
{
$test = trim($sql);
if (
!preg_match('/^SELECT/', $test) &&
!preg_match('/^SHOW/', $test) &&
!preg_match('/^UPDATE `exp_sessions`/', $test) &&
!preg_match('/^INSERT INTO exp_security_hashes/', $test) &&
!preg_match('/^DELETE FROM exp_security_hashes/', $test) &&
!preg_match('/^DELETE FROM `exp_sessions`/', $test) &&
!preg_match('/^INSERT INTO `exp_search_log`/', $test) &&
!preg_match('/^INSERT INTO `exp_search`/', $test)
)
{
file_put_contents('db.log', "$test;\n", FILE_APPEND);
}
}I’m checking the query for a few keywords and excluding them from being logged if they match. My worry here is that my log file would be absolutely huge after a few weeks.
Is this approach madness? With a few more checks, could it be workable?