diff options
author | Melanie | 2009-09-27 21:17:23 +0100 |
---|---|---|
committer | Melanie | 2009-09-27 21:17:23 +0100 |
commit | 8e091f590375d2b63c100e45a187b6cbfa76e161 (patch) | |
tree | d3123da98ecd61eaf419ea3938190ecbacd2e250 /OpenSim | |
parent | Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-8e091f590375d2b63c100e45a187b6cbfa76e161.zip opensim-SC-8e091f590375d2b63c100e45a187b6cbfa76e161.tar.gz opensim-SC-8e091f590375d2b63c100e45a187b6cbfa76e161.tar.bz2 opensim-SC-8e091f590375d2b63c100e45a187b6cbfa76e161.tar.xz |
Add the Migration for the regions table
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Data/IRegionData.cs | 2 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLRegionData.cs | 22 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/Resources/004_GridStore.sql | 6 |
3 files changed, 22 insertions, 8 deletions
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 | |||
39 | public string RegionName; | 39 | public string RegionName; |
40 | public int posX; | 40 | public int posX; |
41 | public int posY; | 41 | public int posY; |
42 | public int sizeX; | ||
43 | public int sizeY; | ||
42 | public Dictionary<string, object> Data; | 44 | public Dictionary<string, object> Data; |
43 | } | 45 | } |
44 | 46 | ||
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 | |||
138 | ret.RegionName = result["regionName"].ToString(); | 138 | ret.RegionName = result["regionName"].ToString(); |
139 | ret.posX = Convert.ToInt32(result["locX"]); | 139 | ret.posX = Convert.ToInt32(result["locX"]); |
140 | ret.posY = Convert.ToInt32(result["locY"]); | 140 | ret.posY = Convert.ToInt32(result["locY"]); |
141 | ret.sizeX = Convert.ToInt32(result["sizeX"]); | ||
142 | ret.sizeY = Convert.ToInt32(result["sizeY"]); | ||
141 | 143 | ||
142 | if (m_ColumnNames == null) | 144 | if (m_ColumnNames == null) |
143 | { | 145 | { |
@@ -188,21 +190,21 @@ namespace OpenSim.Data.MySQL | |||
188 | data.Data.Remove("posX"); | 190 | data.Data.Remove("posX"); |
189 | if (data.Data.ContainsKey("posY")) | 191 | if (data.Data.ContainsKey("posY")) |
190 | data.Data.Remove("posY"); | 192 | data.Data.Remove("posY"); |
193 | if (data.Data.ContainsKey("sizeX")) | ||
194 | data.Data.Remove("sizeX"); | ||
195 | if (data.Data.ContainsKey("sizeY")) | ||
196 | data.Data.Remove("sizeY"); | ||
191 | 197 | ||
192 | string[] fields = new List<string>(data.Data.Keys).ToArray(); | 198 | string[] fields = new List<string>(data.Data.Keys).ToArray(); |
193 | 199 | ||
194 | MySqlCommand cmd = new MySqlCommand(); | 200 | MySqlCommand cmd = new MySqlCommand(); |
195 | 201 | ||
196 | string update = "update `"+m_Realm+"` set "; | 202 | string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY"; |
197 | bool first = true; | ||
198 | foreach (string field in fields) | 203 | foreach (string field in fields) |
199 | { | 204 | { |
200 | if (!first) | 205 | update += ", "; |
201 | update += ", "; | ||
202 | update += "`" + field + "` = ?"+field; | 206 | update += "`" + field + "` = ?"+field; |
203 | 207 | ||
204 | first = false; | ||
205 | |||
206 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); | 208 | cmd.Parameters.AddWithValue("?"+field, data.Data[field]); |
207 | } | 209 | } |
208 | 210 | ||
@@ -214,12 +216,16 @@ namespace OpenSim.Data.MySQL | |||
214 | cmd.CommandText = update; | 216 | cmd.CommandText = update; |
215 | cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); | 217 | cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString()); |
216 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); | 218 | cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString()); |
219 | cmd.Parameters.AddWithValue("?posX", data.posX.ToString()); | ||
220 | cmd.Parameters.AddWithValue("?posY", data.posY.ToString()); | ||
221 | cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString()); | ||
222 | cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString()); | ||
217 | 223 | ||
218 | if (ExecuteNonQuery(cmd) < 1) | 224 | if (ExecuteNonQuery(cmd) < 1) |
219 | { | 225 | { |
220 | string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `" + | 226 | string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `" + |
221 | String.Join("`, `", fields) + | 227 | String.Join("`, `", fields) + |
222 | "`) values ( ?regionID, ?scopeID, ?" + String.Join(", ?", fields) + ")"; | 228 | "`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?" + String.Join(", ?", fields) + ")"; |
223 | 229 | ||
224 | cmd.CommandText = insert; | 230 | cmd.CommandText = insert; |
225 | 231 | ||
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 @@ | |||
1 | BEGIN; | ||
2 | |||
3 | ALTER TABLE regions add column sizeX integer not null default 0; | ||
4 | ALTER TABLE regions add column sizeY integer not null default 0; | ||
5 | |||
6 | COMMIT; | ||