From d674e815bdab29fa4ba47b03bcac99c4b83021e2 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 17 Apr 2012 00:19:36 +0100 Subject: [PATCH] Simplify WebStatsModule by removing the uncompleted migrations section. Use "create table if not exists" instead. Client stats data is transitory data that it is not worth migrating. --- .../Region/UserStatistics/WebStatsModule.cs | 32 ++----------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index dbe9b3fd4f..e593ecd15f 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -90,7 +90,7 @@ namespace OpenSim.Region.UserStatistics dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); dbConn.Open(); - CheckAndUpdateDatabase(dbConn); + CreateTables(dbConn); Prototype_distributor protodep = new Prototype_distributor(); Updater_distributor updatedep = new Updater_distributor(); @@ -237,36 +237,12 @@ namespace OpenSim.Region.UserStatistics return responsedata; } - - public void CheckAndUpdateDatabase(SqliteConnection db) - { - lock (db) - { - // TODO: FIXME: implement stats migrations - const string SQL = @"SELECT * FROM migrations LIMIT 1"; - - using (SqliteCommand cmd = new SqliteCommand(SQL, db)) - { - try - { - cmd.ExecuteNonQuery(); - } - catch (SqliteSyntaxException) - { - CreateTables(db); - } - } - } - } public void CreateTables(SqliteConnection db) { using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db)) { createcmd.ExecuteNonQuery(); - - createcmd.CommandText = SQL_MIGRA_TABLE_CREATE; - createcmd.ExecuteNonQuery(); } } @@ -688,9 +664,7 @@ namespace OpenSim.Region.UserStatistics } #region SQL - private const string SQL_MIGRA_TABLE_CREATE = @"create table migrations(name varchar(100), version int)"; - - private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE stats_session_data ( + private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE IF NOT EXISTS stats_session_data ( session_id VARCHAR(36) NOT NULL PRIMARY KEY, agent_id VARCHAR(36) NOT NULL DEFAULT '', region_id VARCHAR(36) NOT NULL DEFAULT '', @@ -807,8 +781,8 @@ set session_id=:session_id, f_resent=:f_resent, f_send_packet=:f_send_packet WHERE session_id=:session_key"; - #endregion } + #endregion public static class UserSessionUtil {