aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate/NHibernateUserData.cs
diff options
context:
space:
mode:
authorSean Dague2008-06-18 21:14:19 +0000
committerSean Dague2008-06-18 21:14:19 +0000
commit6dea8f34350d03b94ba6f52d8634598cc2de7503 (patch)
treea4191799839c5a084cfbef4294895bb5534dfbe5 /OpenSim/Data/NHibernate/NHibernateUserData.cs
parentadd mysql migrations for nhibernate driver (diff)
downloadopensim-SC_OLD-6dea8f34350d03b94ba6f52d8634598cc2de7503.zip
opensim-SC_OLD-6dea8f34350d03b94ba6f52d8634598cc2de7503.tar.gz
opensim-SC_OLD-6dea8f34350d03b94ba6f52d8634598cc2de7503.tar.bz2
opensim-SC_OLD-6dea8f34350d03b94ba6f52d8634598cc2de7503.tar.xz
clean up the nhibernate definitions to work with mysql
integrate migration support into nhibernate
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateUserData.cs38
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)