From 4ed7ca62b153817a142ded621cc5c5c1b1c055c5 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 1 Dec 2008 07:50:38 +0000 Subject: * From Mantis#2701 - Implements NHibernate data adapter, adds support for MsSql2005 to NHibernate. * Patch courtesy of Adminotech and realXtend. Thanks! --- OpenSim/Data/Migration.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data/Migration.cs') 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 // private static readonly string _migrations_init = "insert into migrations values('migrations', 1)"; // private static readonly string _migrations_find = "select version from migrations where name='migrations'"; + public Migration(DbConnection conn, Assembly assem, string type) { _type = type; @@ -112,6 +113,7 @@ namespace OpenSim.Data DbCommand cmd = _conn.CreateCommand(); cmd.CommandText = _migrations_create; cmd.ExecuteNonQuery(); + cmd.Dispose(); InsertVersion("migrations", 1); } @@ -135,7 +137,7 @@ namespace OpenSim.Data int newversion = kvp.Key; cmd.CommandText = kvp.Value; // we need to up the command timeout to infinite as we might be doing long migrations. - cmd.CommandTimeout = 0; + //cmd.CommandTimeout = 0; cmd.ExecuteNonQuery(); if (version == 0) @@ -147,6 +149,7 @@ namespace OpenSim.Data UpdateVersion(_type, newversion); } version = newversion; + cmd.Dispose(); } } @@ -189,7 +192,7 @@ namespace OpenSim.Data DbCommand cmd = conn.CreateCommand(); try { - cmd.CommandText = "select version from migrations where name='" + type + "' limit 1"; + cmd.CommandText = "select version from migrations where name='" + type +"' order by version desc"; using (IDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) @@ -203,6 +206,7 @@ namespace OpenSim.Data { // Something went wrong, so we're version 0 } + cmd.Dispose(); return version; } @@ -212,6 +216,7 @@ namespace OpenSim.Data cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")"; m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version); cmd.ExecuteNonQuery(); + cmd.Dispose(); } private void UpdateVersion(string type, int version) @@ -220,6 +225,7 @@ namespace OpenSim.Data cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'"; m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version); cmd.ExecuteNonQuery(); + cmd.Dispose(); } // private SortedList GetAllMigrations() -- cgit v1.1