diff options
author | Sean Dague | 2008-05-02 19:39:27 +0000 |
---|---|---|
committer | Sean Dague | 2008-05-02 19:39:27 +0000 |
commit | 17496f3edfd208378f781b3d65ec888ff3ca56a8 (patch) | |
tree | e427581450189109f4848d8e5f6e20a7ca8ecef0 /OpenSim/Data/NHibernate/NHibernateUserData.cs | |
parent | move it out of the Types namespace (diff) | |
download | opensim-SC_OLD-17496f3edfd208378f781b3d65ec888ff3ca56a8.zip opensim-SC_OLD-17496f3edfd208378f781b3d65ec888ff3ca56a8.tar.gz opensim-SC_OLD-17496f3edfd208378f781b3d65ec888ff3ca56a8.tar.bz2 opensim-SC_OLD-17496f3edfd208378f781b3d65ec888ff3ca56a8.tar.xz |
in theory fix the user table mapping
Diffstat (limited to 'OpenSim/Data/NHibernate/NHibernateUserData.cs')
-rw-r--r-- | OpenSim/Data/NHibernate/NHibernateUserData.cs | 22 |
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; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Text.RegularExpressions; | ||
32 | using libsecondlife; | 33 | using libsecondlife; |
33 | using log4net; | 34 | using log4net; |
34 | using NHibernate; | 35 | using NHibernate; |
35 | using NHibernate.Cfg; | 36 | using NHibernate.Cfg; |
36 | using NHibernate.Expression; | 37 | using NHibernate.Expression; |
37 | using NHibernate.Mapping.Attributes; | 38 | using NHibernate.Mapping.Attributes; |
39 | using NHibernate.Tool.hbm2ddl; | ||
38 | using OpenSim.Framework; | 40 | using OpenSim.Framework; |
39 | using Environment=NHibernate.Cfg.Environment; | 41 | using 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) |