diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs
index 87594db3a1..8983753008 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 ffb2199169..0eabf0ee98 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