From 17496f3edfd208378f781b3d65ec888ff3ca56a8 Mon Sep 17 00:00:00 2001
From: Sean Dague
Date: Fri, 2 May 2008 19:39:27 +0000
Subject: in theory fix the user table mapping
---
OpenSim/Data/NHibernate/NHibernateUserData.cs | 22 ++++++++++++++++++++++
.../NHibernate/Resources/UserAppearance.hbm.xml | 4 ++--
2 files changed, 24 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Data/NHibernate')
diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs
index 87594db..8983753 100644
--- a/OpenSim/Data/NHibernate/NHibernateUserData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs
@@ -29,12 +29,14 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
+using System.Text.RegularExpressions;
using libsecondlife;
using log4net;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Expression;
using NHibernate.Mapping.Attributes;
+using NHibernate.Tool.hbm2ddl;
using OpenSim.Framework;
using Environment=NHibernate.Cfg.Environment;
@@ -78,6 +80,26 @@ namespace OpenSim.Data.NHibernate
// new SchemaExport(cfg).Create(true, true);
factory = cfg.BuildSessionFactory();
+ InitDB();
+ }
+
+ private void InitDB()
+ {
+ string regex = @"no such table: Users";
+ Regex RE = new Regex(regex, RegexOptions.Multiline);
+ try {
+ using(ISession session = factory.OpenSession()) {
+ session.Load(typeof(InventoryItemBase), LLUUID.Zero);
+ }
+ } catch (ObjectNotFoundException e) {
+ // 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);
+ }
+ }
}
private bool ExistsUser(LLUUID uuid)
diff --git a/OpenSim/Data/NHibernate/Resources/UserAppearance.hbm.xml b/OpenSim/Data/NHibernate/Resources/UserAppearance.hbm.xml
index ffb2199..0eabf0e 100644
--- a/OpenSim/Data/NHibernate/Resources/UserAppearance.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/UserAppearance.hbm.xml
@@ -30,8 +30,8 @@
-
-
+
+
\ No newline at end of file
--
cgit v1.1