diff options
Diffstat (limited to 'OpenSim/Data')
-rw-r--r-- | OpenSim/Data/NHibernate/NHibernateUserData.cs | 22 | ||||
-rw-r--r-- | OpenSim/Data/NHibernate/Resources/UserAppearance.hbm.xml | 4 |
2 files changed, 24 insertions, 2 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) |
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 @@ | |||
30 | <property name="UnderPantsAsset" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> | 30 | <property name="UnderPantsAsset" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> |
31 | <property name="SkirtItem" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> | 31 | <property name="SkirtItem" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> |
32 | <property name="SkirtAsset" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> | 32 | <property name="SkirtAsset" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> |
33 | <property name="Texture" type="byte[]" /> | 33 | <property name="Texture" type="binary" /> |
34 | <property name="VisualParams" type="byte[]" /> | 34 | <property name="VisualParams" type="binary" /> |
35 | <property name="Serial" type="int" /> | 35 | <property name="Serial" type="int" /> |
36 | </class> | 36 | </class> |
37 | </hibernate-mapping> \ No newline at end of file | 37 | </hibernate-mapping> \ No newline at end of file |