aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate/NHibernateUserData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/NHibernate/NHibernateUserData.cs')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateUserData.cs22
1 files changed, 22 insertions, 0 deletions
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;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Text.RegularExpressions;
32using libsecondlife; 33using libsecondlife;
33using log4net; 34using log4net;
34using NHibernate; 35using NHibernate;
35using NHibernate.Cfg; 36using NHibernate.Cfg;
36using NHibernate.Expression; 37using NHibernate.Expression;
37using NHibernate.Mapping.Attributes; 38using NHibernate.Mapping.Attributes;
39using NHibernate.Tool.hbm2ddl;
38using OpenSim.Framework; 40using OpenSim.Framework;
39using Environment=NHibernate.Cfg.Environment; 41using Environment=NHibernate.Cfg.Environment;
40 42
@@ -78,6 +80,26 @@ namespace OpenSim.Data.NHibernate
78 // new SchemaExport(cfg).Create(true, true); 80 // new SchemaExport(cfg).Create(true, true);
79 81
80 factory = cfg.BuildSessionFactory(); 82 factory = cfg.BuildSessionFactory();
83 InitDB();
84 }
85
86 private void InitDB()
87 {
88 string regex = @"no such table: Users";
89 Regex RE = new Regex(regex, RegexOptions.Multiline);
90 try {
91 using(ISession session = factory.OpenSession()) {
92 session.Load(typeof(InventoryItemBase), LLUUID.Zero);
93 }
94 } catch (ObjectNotFoundException e) {
95 // yes, we know it's not there, but that's ok
96 } catch (ADOException e) {
97 Match m = RE.Match(e.ToString());
98 if(m.Success) {
99 // We don't have this table, so create it.
100 new SchemaExport(cfg).Create(true, true);
101 }
102 }
81 } 103 }
82 104
83 private bool ExistsUser(LLUUID uuid) 105 private bool ExistsUser(LLUUID uuid)