From 6dea8f34350d03b94ba6f52d8634598cc2de7503 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 18 Jun 2008 21:14:19 +0000 Subject: clean up the nhibernate definitions to work with mysql integrate migration support into nhibernate --- OpenSim/Data/NHibernate/NHibernateInventoryData.cs | 42 +++------------------- 1 file changed, 5 insertions(+), 37 deletions(-) (limited to 'OpenSim/Data/NHibernate/NHibernateInventoryData.cs') diff --git a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs index 902ecfb..2b36386 100644 --- a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs +++ b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs @@ -62,6 +62,7 @@ namespace OpenSim.Data.NHibernate // TODO: make this a real exception type throw new Exception("Malformed Inventory connection string '" + connect + "'"); } + string dialect = parts[0]; // Establish NHibernate Connection cfg = new Configuration(); @@ -74,46 +75,13 @@ namespace OpenSim.Data.NHibernate cfg.SetProperty(Environment.ConnectionString, parts[2]); cfg.AddAssembly("OpenSim.Data.NHibernate"); - HbmSerializer.Default.Validate = true; - using (MemoryStream stream = - HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly())) - cfg.AddInputStream(stream); - - // If uncommented this will auto create tables, but it - // does drops of the old tables, so we need a smarter way - // to acturally manage this. - - // new SchemaExport(cfg).Create(true, true); - factory = cfg.BuildSessionFactory(); - InitDB(); - } + // This actually does the roll forward assembly stuff + Assembly assem = GetType().Assembly; + Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore"); + m.Update(); - private void InitDB() - { - string regex = @"no such table: Inventory"; - Regex RE = new Regex(regex, RegexOptions.Multiline); - try - { - using (ISession session = factory.OpenSession()) - { - session.Load(typeof(InventoryItemBase), LLUUID.Zero); - } - } - catch (ObjectNotFoundException) - { - // yes, we know it's not there, but that's ok - } - catch (ADOException e) - { - Match m = RE.Match(e.ToString()); - if (m.Success) - { - // We don't have this table, so create it. - new SchemaExport(cfg).Create(true, true); - } - } } /***************************************************************** -- cgit v1.1