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.
0.7.3-extended
Justin Clark-Casey (justincc) 2012-04-17 00:19:36 +01:00
parent c2e696d686
commit d674e815bd
1 changed files with 3 additions and 29 deletions

View File

@ -90,7 +90,7 @@ namespace OpenSim.Region.UserStatistics
dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3");
dbConn.Open(); dbConn.Open();
CheckAndUpdateDatabase(dbConn); CreateTables(dbConn);
Prototype_distributor protodep = new Prototype_distributor(); Prototype_distributor protodep = new Prototype_distributor();
Updater_distributor updatedep = new Updater_distributor(); Updater_distributor updatedep = new Updater_distributor();
@ -237,36 +237,12 @@ namespace OpenSim.Region.UserStatistics
return responsedata; 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) public void CreateTables(SqliteConnection db)
{ {
using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db)) using (SqliteCommand createcmd = new SqliteCommand(SQL_STATS_TABLE_CREATE, db))
{ {
createcmd.ExecuteNonQuery(); createcmd.ExecuteNonQuery();
createcmd.CommandText = SQL_MIGRA_TABLE_CREATE;
createcmd.ExecuteNonQuery();
} }
} }
@ -688,9 +664,7 @@ namespace OpenSim.Region.UserStatistics
} }
#region SQL #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 IF NOT EXISTS stats_session_data (
private const string SQL_STATS_TABLE_CREATE = @"CREATE TABLE stats_session_data (
session_id VARCHAR(36) NOT NULL PRIMARY KEY, session_id VARCHAR(36) NOT NULL PRIMARY KEY,
agent_id VARCHAR(36) NOT NULL DEFAULT '', agent_id VARCHAR(36) NOT NULL DEFAULT '',
region_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_resent=:f_resent,
f_send_packet=:f_send_packet f_send_packet=:f_send_packet
WHERE session_id=:session_key"; WHERE session_id=:session_key";
#endregion
} }
#endregion
public static class UserSessionUtil public static class UserSessionUtil
{ {