From 31d689aa0da5d4319281148ef1ea9a21f86ffe86 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Wed, 5 Sep 2012 12:49:53 +0000 Subject: [PATCH] Created a draft of the migration script --- src/messenger/webim/install/migrate.php | 69 +++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/messenger/webim/install/migrate.php diff --git a/src/messenger/webim/install/migrate.php b/src/messenger/webim/install/migrate.php new file mode 100644 index 00000000..d51b4a11 --- /dev/null +++ b/src/messenger/webim/install/migrate.php @@ -0,0 +1,69 @@ +throwExeptions(true); + +$update_datetime = array( + '{chatthread}' => array( + 'dtmcreated', + 'dtmchatstarted', + 'dtmmodified', + 'lastpinguser', + 'lastpingagent' + ), + '{chatmessage}' => array( + 'dtmcreated' + ), + '{chatoperator}' => array( + 'dtmlastvisited', + 'dtmrestore' + ), + '{chatban}' => array( + 'dtmcreated', + 'dtmtill' + ), + '{chatsitevisitor}' => array( + 'firsttime', + 'lasttime', + 'invitationtime' + ), + '{visitedpage}' => array( + 'visittime' + ), + '{visitedpagestatistics}' => array( + 'visittime' + ) +); + +foreach($update_datetime as $table => $columns) { + echo("Table: {$table}
"); + foreach($columns as $column) { + echo("-- Column: {$column}
"); + $db->query("ALTER TABLE {$table} CHANGE {$column} {$column}_tmp datetime"); + $db->query("ALTER TABLE {$table} ADD COLUMN {$column} int NOT NULL DEFAULT 0 AFTER {$column}_tmp"); + $db->query("UPDATE {$table} SET {$column} = UNIX_TIMESTAMP({$column}_tmp)"); + $db->query("ALTER TABLE {$table} DROP COLUMN {$column}_tmp"); + } +} + + +?> \ No newline at end of file