Commit 451a16be by Scott

Move event logger upgrade to plugin

parent 391068b6
...@@ -1469,13 +1469,6 @@ ...@@ -1469,13 +1469,6 @@
break; break;
case 63: case 63:
// convert IP addresses to new binary format
if (isset($keydbtables[qa_db_add_table_prefix('eventlog')])) {
$locktablesquery.=', ^eventlog WRITE';
qa_db_upgrade_query($locktablesquery);
qa_db_upgrade_query('ALTER TABLE ^eventlog MODIFY ipaddress VARCHAR(45) CHARACTER SET ascii');
}
qa_db_upgrade_query('ALTER TABLE ^cookies MODIFY writeip VARBINARY(16) NULL DEFAULT NULL, MODIFY createip VARBINARY(16) NULL DEFAULT NULL'); qa_db_upgrade_query('ALTER TABLE ^cookies MODIFY writeip VARBINARY(16) NULL DEFAULT NULL, MODIFY createip VARBINARY(16) NULL DEFAULT NULL');
qa_db_upgrade_query('UPDATE ^cookies SET writeip = UNHEX(HEX(CAST(writeip AS UNSIGNED))), createip = UNHEX(HEX(CAST(createip AS UNSIGNED)))'); qa_db_upgrade_query('UPDATE ^cookies SET writeip = UNHEX(HEX(CAST(writeip AS UNSIGNED))), createip = UNHEX(HEX(CAST(createip AS UNSIGNED)))');
......
...@@ -28,12 +28,13 @@ class qa_event_logger ...@@ -28,12 +28,13 @@ class qa_event_logger
$tablename=qa_db_add_table_prefix('eventlog'); $tablename=qa_db_add_table_prefix('eventlog');
if (!in_array($tablename, $table_list)) { if (!in_array($tablename, $table_list)) {
// table does not exist, so create it
require_once QA_INCLUDE_DIR.'app/users.php'; require_once QA_INCLUDE_DIR.'app/users.php';
require_once QA_INCLUDE_DIR.'db/maxima.php'; require_once QA_INCLUDE_DIR.'db/maxima.php';
return 'CREATE TABLE ^eventlog ('. return 'CREATE TABLE ^eventlog ('.
'datetime DATETIME NOT NULL,'. 'datetime DATETIME NOT NULL,'.
'ipaddress VARCHAR (45),'. 'ipaddress VARCHAR (45) CHARACTER SET ascii,'.
'userid '.qa_get_mysql_user_column_type().','. 'userid '.qa_get_mysql_user_column_type().','.
'handle VARCHAR('.QA_DB_MAX_HANDLE_LENGTH.'),'. 'handle VARCHAR('.QA_DB_MAX_HANDLE_LENGTH.'),'.
'cookieid BIGINT UNSIGNED,'. 'cookieid BIGINT UNSIGNED,'.
...@@ -44,6 +45,13 @@ class qa_event_logger ...@@ -44,6 +45,13 @@ class qa_event_logger
'KEY userid (userid),'. 'KEY userid (userid),'.
'KEY event (event)'. 'KEY event (event)'.
') ENGINE=MyISAM DEFAULT CHARSET=utf8'; ') ENGINE=MyISAM DEFAULT CHARSET=utf8';
} else {
// table exists: check it has the correct schema
$column = qa_db_read_one_assoc(qa_db_query_sub('SHOW COLUMNS FROM ^eventlog WHERE Field="ipaddress"'));
if (strtolower($column['Type']) !== 'varchar(45)') {
// upgrade to handle IPv6
return 'ALTER TABLE ^eventlog MODIFY ipaddress VARCHAR(45) CHARACTER SET ascii';
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment