diff options
author | Adam Frisby | 2008-12-01 07:50:38 +0000 |
---|---|---|
committer | Adam Frisby | 2008-12-01 07:50:38 +0000 |
commit | 4ed7ca62b153817a142ded621cc5c5c1b1c055c5 (patch) | |
tree | e8cad8abe60b6becd22da1a8d2c2dfefbf6f9784 /OpenSim/Data/Migration.cs | |
parent | Mantis #2729 (diff) | |
download | opensim-SC_OLD-4ed7ca62b153817a142ded621cc5c5c1b1c055c5.zip opensim-SC_OLD-4ed7ca62b153817a142ded621cc5c5c1b1c055c5.tar.gz opensim-SC_OLD-4ed7ca62b153817a142ded621cc5c5c1b1c055c5.tar.bz2 opensim-SC_OLD-4ed7ca62b153817a142ded621cc5c5c1b1c055c5.tar.xz |
* From Mantis#2701 - Implements NHibernate data adapter, adds support for MsSql2005 to NHibernate.
* Patch courtesy of Adminotech and realXtend. Thanks!
Diffstat (limited to 'OpenSim/Data/Migration.cs')
-rw-r--r-- | OpenSim/Data/Migration.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/OpenSim/Data/Migration.cs b/OpenSim/Data/Migration.cs index 8fbf789..332b8ec 100644 --- a/OpenSim/Data/Migration.cs +++ b/OpenSim/Data/Migration.cs | |||
@@ -82,6 +82,7 @@ namespace OpenSim.Data | |||
82 | // private static readonly string _migrations_init = "insert into migrations values('migrations', 1)"; | 82 | // private static readonly string _migrations_init = "insert into migrations values('migrations', 1)"; |
83 | // private static readonly string _migrations_find = "select version from migrations where name='migrations'"; | 83 | // private static readonly string _migrations_find = "select version from migrations where name='migrations'"; |
84 | 84 | ||
85 | |||
85 | public Migration(DbConnection conn, Assembly assem, string type) | 86 | public Migration(DbConnection conn, Assembly assem, string type) |
86 | { | 87 | { |
87 | _type = type; | 88 | _type = type; |
@@ -112,6 +113,7 @@ namespace OpenSim.Data | |||
112 | DbCommand cmd = _conn.CreateCommand(); | 113 | DbCommand cmd = _conn.CreateCommand(); |
113 | cmd.CommandText = _migrations_create; | 114 | cmd.CommandText = _migrations_create; |
114 | cmd.ExecuteNonQuery(); | 115 | cmd.ExecuteNonQuery(); |
116 | cmd.Dispose(); | ||
115 | 117 | ||
116 | InsertVersion("migrations", 1); | 118 | InsertVersion("migrations", 1); |
117 | } | 119 | } |
@@ -135,7 +137,7 @@ namespace OpenSim.Data | |||
135 | int newversion = kvp.Key; | 137 | int newversion = kvp.Key; |
136 | cmd.CommandText = kvp.Value; | 138 | cmd.CommandText = kvp.Value; |
137 | // we need to up the command timeout to infinite as we might be doing long migrations. | 139 | // we need to up the command timeout to infinite as we might be doing long migrations. |
138 | cmd.CommandTimeout = 0; | 140 | //cmd.CommandTimeout = 0; |
139 | cmd.ExecuteNonQuery(); | 141 | cmd.ExecuteNonQuery(); |
140 | 142 | ||
141 | if (version == 0) | 143 | if (version == 0) |
@@ -147,6 +149,7 @@ namespace OpenSim.Data | |||
147 | UpdateVersion(_type, newversion); | 149 | UpdateVersion(_type, newversion); |
148 | } | 150 | } |
149 | version = newversion; | 151 | version = newversion; |
152 | cmd.Dispose(); | ||
150 | } | 153 | } |
151 | } | 154 | } |
152 | 155 | ||
@@ -189,7 +192,7 @@ namespace OpenSim.Data | |||
189 | DbCommand cmd = conn.CreateCommand(); | 192 | DbCommand cmd = conn.CreateCommand(); |
190 | try | 193 | try |
191 | { | 194 | { |
192 | cmd.CommandText = "select version from migrations where name='" + type + "' limit 1"; | 195 | cmd.CommandText = "select version from migrations where name='" + type +"' order by version desc"; |
193 | using (IDataReader reader = cmd.ExecuteReader()) | 196 | using (IDataReader reader = cmd.ExecuteReader()) |
194 | { | 197 | { |
195 | if (reader.Read()) | 198 | if (reader.Read()) |
@@ -203,6 +206,7 @@ namespace OpenSim.Data | |||
203 | { | 206 | { |
204 | // Something went wrong, so we're version 0 | 207 | // Something went wrong, so we're version 0 |
205 | } | 208 | } |
209 | cmd.Dispose(); | ||
206 | return version; | 210 | return version; |
207 | } | 211 | } |
208 | 212 | ||
@@ -212,6 +216,7 @@ namespace OpenSim.Data | |||
212 | cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; | 216 | cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; |
213 | m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version); | 217 | m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version); |
214 | cmd.ExecuteNonQuery(); | 218 | cmd.ExecuteNonQuery(); |
219 | cmd.Dispose(); | ||
215 | } | 220 | } |
216 | 221 | ||
217 | private void UpdateVersion(string type, int version) | 222 | private void UpdateVersion(string type, int version) |
@@ -220,6 +225,7 @@ namespace OpenSim.Data | |||
220 | cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; | 225 | cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; |
221 | m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version); | 226 | m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version); |
222 | cmd.ExecuteNonQuery(); | 227 | cmd.ExecuteNonQuery(); |
228 | cmd.Dispose(); | ||
223 | } | 229 | } |
224 | 230 | ||
225 | // private SortedList<int, string> GetAllMigrations() | 231 | // private SortedList<int, string> GetAllMigrations() |