diff options
Diffstat (limited to 'OpenSim/Data/NHibernate/NHibernateUserData.cs')
-rw-r--r-- | OpenSim/Data/NHibernate/NHibernateUserData.cs | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs index af9020d..044c14a 100644 --- a/OpenSim/Data/NHibernate/NHibernateUserData.cs +++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs | |||
@@ -61,6 +61,7 @@ namespace OpenSim.Data.NHibernate | |||
61 | // TODO: make this a real exception type | 61 | // TODO: make this a real exception type |
62 | throw new Exception("Malformed Inventory connection string '" + connect + "'"); | 62 | throw new Exception("Malformed Inventory connection string '" + connect + "'"); |
63 | } | 63 | } |
64 | string dialect = parts[0]; | ||
64 | 65 | ||
65 | // This is stubbing for now, it will become dynamic later and support different db backends | 66 | // This is stubbing for now, it will become dynamic later and support different db backends |
66 | cfg = new Configuration(); | 67 | cfg = new Configuration(); |
@@ -73,41 +74,12 @@ namespace OpenSim.Data.NHibernate | |||
73 | cfg.SetProperty(Environment.ConnectionString, parts[2]); | 74 | cfg.SetProperty(Environment.ConnectionString, parts[2]); |
74 | cfg.AddAssembly("OpenSim.Data.NHibernate"); | 75 | cfg.AddAssembly("OpenSim.Data.NHibernate"); |
75 | 76 | ||
76 | HbmSerializer.Default.Validate = true; | ||
77 | using (MemoryStream stream = | ||
78 | HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly())) | ||
79 | cfg.AddInputStream(stream); | ||
80 | |||
81 | // new SchemaExport(cfg).Create(true, true); | ||
82 | |||
83 | factory = cfg.BuildSessionFactory(); | 77 | factory = cfg.BuildSessionFactory(); |
84 | InitDB(); | ||
85 | } | ||
86 | 78 | ||
87 | private void InitDB() | 79 | // This actually does the roll forward assembly stuff |
88 | { | 80 | Assembly assem = GetType().Assembly; |
89 | string regex = @"no such table: UserProfiles"; | 81 | Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore"); |
90 | Regex RE = new Regex(regex, RegexOptions.Multiline); | 82 | m.Update(); |
91 | try | ||
92 | { | ||
93 | using (ISession session = factory.OpenSession()) | ||
94 | { | ||
95 | session.Load(typeof(UserProfileData), LLUUID.Zero); | ||
96 | } | ||
97 | } | ||
98 | catch (ObjectNotFoundException) | ||
99 | { | ||
100 | // yes, we know it's not there, but that's ok | ||
101 | } | ||
102 | catch (ADOException e) | ||
103 | { | ||
104 | Match m = RE.Match(e.ToString()); | ||
105 | if (m.Success) | ||
106 | { | ||
107 | // We don't have this table, so create it. | ||
108 | new SchemaExport(cfg).Create(true, true); | ||
109 | } | ||
110 | } | ||
111 | } | 83 | } |
112 | 84 | ||
113 | private bool ExistsUser(LLUUID uuid) | 85 | private bool ExistsUser(LLUUID uuid) |