From 8e091f590375d2b63c100e45a187b6cbfa76e161 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 27 Sep 2009 21:17:23 +0100 Subject: Add the Migration for the regions table --- OpenSim/Data/IRegionData.cs | 2 ++ OpenSim/Data/MySQL/MySQLRegionData.cs | 22 ++++++++++++++-------- OpenSim/Data/MySQL/Resources/004_GridStore.sql | 6 ++++++ 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/004_GridStore.sql (limited to 'OpenSim') diff --git a/OpenSim/Data/IRegionData.cs b/OpenSim/Data/IRegionData.cs index c5201ea..7a607ab 100644 --- a/OpenSim/Data/IRegionData.cs +++ b/OpenSim/Data/IRegionData.cs @@ -39,6 +39,8 @@ namespace OpenSim.Data public string RegionName; public int posX; public int posY; + public int sizeX; + public int sizeY; public Dictionary Data; } diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs index ced26a4..0d71c23 100644 --- a/OpenSim/Data/MySQL/MySQLRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLRegionData.cs @@ -138,6 +138,8 @@ namespace OpenSim.Data.MySQL ret.RegionName = result["regionName"].ToString(); ret.posX = Convert.ToInt32(result["locX"]); ret.posY = Convert.ToInt32(result["locY"]); + ret.sizeX = Convert.ToInt32(result["sizeX"]); + ret.sizeY = Convert.ToInt32(result["sizeY"]); if (m_ColumnNames == null) { @@ -188,21 +190,21 @@ namespace OpenSim.Data.MySQL data.Data.Remove("posX"); if (data.Data.ContainsKey("posY")) data.Data.Remove("posY"); + if (data.Data.ContainsKey("sizeX")) + data.Data.Remove("sizeX"); + if (data.Data.ContainsKey("sizeY")) + data.Data.Remove("sizeY"); string[] fields = new List(data.Data.Keys).ToArray(); MySqlCommand cmd = new MySqlCommand(); - string update = "update `"+m_Realm+"` set "; - bool first = true; + string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; foreach (string field in fields) { - if (!first) - update += ", "; + update += ", "; update += "`" + field + "` = ?"+field; - first = false; - cmd.Parameters.AddWithValue("?"+field, data.Data[field]); } @@ -214,12 +216,16 @@ namespace OpenSim.Data.MySQL cmd.CommandText = update; cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); + cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); + cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); + cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); + cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); if (ExecuteNonQuery(cmd) < 1) { - string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `" + + string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `" + String.Join("`, `", fields) + - "`) values ( ?regionID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; + "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?" + String.Join(", ?", fields) + ")"; cmd.CommandText = insert; diff --git a/OpenSim/Data/MySQL/Resources/004_GridStore.sql b/OpenSim/Data/MySQL/Resources/004_GridStore.sql new file mode 100644 index 0000000..2238a88 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/004_GridStore.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE regions add column sizeX integer not null default 0; +ALTER TABLE regions add column sizeY integer not null default 0; + +COMMIT; -- cgit v1.1