aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
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
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 'OpenSim/Data')
-rw-r--r--OpenSim/Data/NHibernate/NHibernateAssetData.cs27
-rw-r--r--OpenSim/Data/NHibernate/NHibernateInventoryData.cs42
-rw-r--r--OpenSim/Data/NHibernate/NHibernateUserData.cs38
-rw-r--r--OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml8
-rw-r--r--OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml4
-rw-r--r--OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml16
-rw-r--r--OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml4
-rw-r--r--OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml8
8 files changed, 30 insertions, 117 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateAssetData.cs b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
index bb5a3f3..5c691a7 100644
--- a/OpenSim/Data/NHibernate/NHibernateAssetData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateAssetData.cs
@@ -93,33 +93,6 @@ namespace OpenSim.Data.NHibernate
93 Assembly assem = GetType().Assembly; 93 Assembly assem = GetType().Assembly;
94 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore"); 94 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore");
95 m.Update(); 95 m.Update();
96
97 }
98
99 private void InitDB()
100 {
101 string regex = @"no such table: Assets";
102 Regex RE = new Regex(regex, RegexOptions.Multiline);
103 try
104 {
105 using (ISession session = factory.OpenSession())
106 {
107 session.Load(typeof(AssetBase), LLUUID.Zero);
108 }
109 }
110 catch (ObjectNotFoundException)
111 {
112 // yes, we know it's not there, but that's ok
113 }
114 catch (ADOException e)
115 {
116 Match m = RE.Match(e.ToString());
117 if (m.Success)
118 {
119 // We don't have this table, so create it.
120 new SchemaExport(cfg).Create(true, true);
121 }
122 }
123 } 96 }
124 97
125 override public AssetBase FetchAsset(LLUUID uuid) 98 override public AssetBase FetchAsset(LLUUID uuid)
diff --git a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
index 902ecfb..2b36386 100644
--- a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
@@ -62,6 +62,7 @@ namespace OpenSim.Data.NHibernate
62 // TODO: make this a real exception type 62 // TODO: make this a real exception type
63 throw new Exception("Malformed Inventory connection string '" + connect + "'"); 63 throw new Exception("Malformed Inventory connection string '" + connect + "'");
64 } 64 }
65 string dialect = parts[0];
65 66
66 // Establish NHibernate Connection 67 // Establish NHibernate Connection
67 cfg = new Configuration(); 68 cfg = new Configuration();
@@ -74,46 +75,13 @@ namespace OpenSim.Data.NHibernate
74 cfg.SetProperty(Environment.ConnectionString, parts[2]); 75 cfg.SetProperty(Environment.ConnectionString, parts[2]);
75 cfg.AddAssembly("OpenSim.Data.NHibernate"); 76 cfg.AddAssembly("OpenSim.Data.NHibernate");
76 77
77 HbmSerializer.Default.Validate = true;
78 using (MemoryStream stream =
79 HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly()))
80 cfg.AddInputStream(stream);
81
82 // If uncommented this will auto create tables, but it
83 // does drops of the old tables, so we need a smarter way
84 // to acturally manage this.
85
86 // new SchemaExport(cfg).Create(true, true);
87
88 factory = cfg.BuildSessionFactory(); 78 factory = cfg.BuildSessionFactory();
89 79
90 InitDB(); 80 // This actually does the roll forward assembly stuff
91 } 81 Assembly assem = GetType().Assembly;
82 Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore");
83 m.Update();
92 84
93 private void InitDB()
94 {
95 string regex = @"no such table: Inventory";
96 Regex RE = new Regex(regex, RegexOptions.Multiline);
97 try
98 {
99 using (ISession session = factory.OpenSession())
100 {
101 session.Load(typeof(InventoryItemBase), LLUUID.Zero);
102 }
103 }
104 catch (ObjectNotFoundException)
105 {
106 // yes, we know it's not there, but that's ok
107 }
108 catch (ADOException e)
109 {
110 Match m = RE.Match(e.ToString());
111 if (m.Success)
112 {
113 // We don't have this table, so create it.
114 new SchemaExport(cfg).Create(true, true);
115 }
116 }
117 } 85 }
118 86
119 /***************************************************************** 87 /*****************************************************************
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)
diff --git a/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml
index 12ab981..261c136 100644
--- a/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml
@@ -4,10 +4,10 @@
4 <id name="FullID" column="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> 4 <id name="FullID" column="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate">
5 <generator class="assigned" /> 5 <generator class="assigned" />
6 </id> 6 </id>
7 <property name="Type" type="SByte" /> 7 <property name="Type" type="Int16" />
8 <property name="InvType" type="SByte" /> 8 <property name="InvType" type="Int16" />
9 <property name="Name" type="String" length="50" /> 9 <property name="Name" type="String" length="64" />
10 <property name="Description" type="String" length="50" /> 10 <property name="Description" type="String" length="64" />
11 <property name="Local" type="boolean" /> 11 <property name="Local" type="boolean" />
12 <property name="Temporary" type="boolean" /> 12 <property name="Temporary" type="boolean" />
13 <property name="Data" type="binary" /> 13 <property name="Data" type="binary" />
diff --git a/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml
index 4411071..8c6d02b 100644
--- a/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml
@@ -4,8 +4,8 @@
4 <id name="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> 4 <id name="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate">
5 <generator class="assigned" /> 5 <generator class="assigned" />
6 </id> 6 </id>
7 <property name="Type" type="short" /> 7 <property name="Type" type="Int32" />
8 <property name="Version" type="UInt16" /> 8 <property name="Version" type="Int32" />
9 <property name="ParentID" index="folder_parent_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 9 <property name="ParentID" index="folder_parent_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
10 <property name="Owner" index="folder_owner_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 10 <property name="Owner" index="folder_owner_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
11 <property name="Name" type="String" length="64" /> 11 <property name="Name" type="String" length="64" />
diff --git a/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml
index c2e5c17..debb2e5 100644
--- a/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml
@@ -4,23 +4,23 @@
4 <id name="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> 4 <id name="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate">
5 <generator class="assigned" /> 5 <generator class="assigned" />
6 </id> 6 </id>
7 <property name="InvType" type="int" /> 7 <property name="InvType" type="Int16" />
8 <property name="AssetType" type="int" /> 8 <property name="AssetType" type="Int16" />
9 <property name="AssetID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 9 <property name="AssetID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
10 <property name="Folder" index="item_folder_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 10 <property name="Folder" index="item_folder_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
11 <property name="Owner" index="item_owner_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 11 <property name="Owner" index="item_owner_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
12 <property name="Creator" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 12 <property name="Creator" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
13 <property name="Name" type="String" length="64" /> 13 <property name="Name" type="String" length="64" />
14 <property name="Description" type="String" length="64" /> 14 <property name="Description" type="String" length="64" />
15 <property name="NextPermissions" type="UInt32" /> 15 <property name="NextPermissions" type="Int32" />
16 <property name="CurrentPermissions" type="UInt32" /> 16 <property name="CurrentPermissions" type="Int32" />
17 <property name="BasePermissions" type="UInt32" /> 17 <property name="BasePermissions" type="Int32" />
18 <property name="EveryOnePermissions" type="UInt32" /> 18 <property name="EveryOnePermissions" type="Int32" />
19 <property name="GroupID" index="item_group_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 19 <property name="GroupID" index="item_group_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
20 <property name="GroupOwned" type="boolean" /> 20 <property name="GroupOwned" type="boolean" />
21 <property name="SalePrice" type="Int32" /> 21 <property name="SalePrice" type="Int32" />
22 <property name="SaleType" type="Byte" /> 22 <property name="SaleType" type="Int16" />
23 <property name="Flags" type="UInt32" /> 23 <property name="Flags" type="Int32" />
24 <property name="CreationDate" type="Int32" /> 24 <property name="CreationDate" type="Int32" />
25 </class> 25 </class>
26</hibernate-mapping> \ No newline at end of file 26</hibernate-mapping> \ No newline at end of file
diff --git a/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml b/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml
index b2abeae..718cb98 100644
--- a/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml
@@ -5,7 +5,7 @@
5 <generator class="assigned" /> 5 <generator class="assigned" />
6 </id> 6 </id>
7 <property name="AgentIP" type="String" length="24" /> 7 <property name="AgentIP" type="String" length="24" />
8 <property name="AgentPort" type="UInt32" /> 8 <property name="AgentPort" type="Int32" />
9 <property name="AgentOnline" type="boolean" /> 9 <property name="AgentOnline" type="boolean" />
10 <property name="SessionID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 10 <property name="SessionID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
11 <property name="SecureSessionID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 11 <property name="SecureSessionID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
@@ -13,7 +13,7 @@
13 <property name="Region" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 13 <property name="Region" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
14 <property name="LoginTime" type="Int32" /> 14 <property name="LoginTime" type="Int32" />
15 <property name="LogoutTime" type="Int32" /> 15 <property name="LogoutTime" type="Int32" />
16 <property name="Handle" type="UInt64" /> 16 <property name="Handle" type="Int64" />
17 <property name="PositionX" type="Single" /> 17 <property name="PositionX" type="Single" />
18 <property name="PositionY" type="Single" /> 18 <property name="PositionY" type="Single" />
19 <property name="PositionZ" type="Single" /> 19 <property name="PositionZ" type="Single" />
diff --git a/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml b/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml
index 3e4b5aa..cb83e2c 100644
--- a/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml
+++ b/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml
@@ -9,16 +9,16 @@
9 <property name="PasswordHash" type="String" length="32" /> 9 <property name="PasswordHash" type="String" length="32" />
10 <property name="PasswordSalt" type="String" length="32" /> 10 <property name="PasswordSalt" type="String" length="32" />
11 <property name="WebLoginKey" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 11 <property name="WebLoginKey" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
12 <property name="HomeRegionX" type="UInt32" /> 12 <property name="HomeRegionX" type="Int32" />
13 <property name="HomeRegionY" type="UInt32" /> 13 <property name="HomeRegionY" type="Int32" />
14 <property name="HomeLocationX" type="Single" /> 14 <property name="HomeLocationX" type="Single" />
15 <property name="HomeLocationY" type="Single" /> 15 <property name="HomeLocationY" type="Single" />
16 <property name="HomeLocationZ" type="Single" /> 16 <property name="HomeLocationZ" type="Single" />
17 <property name="HomeLookAtX" type="Single" /> 17 <property name="HomeLookAtX" type="Single" />
18 <property name="HomeLookAtY" type="Single" /> 18 <property name="HomeLookAtY" type="Single" />
19 <property name="HomeLookAtZ" type="Single" /> 19 <property name="HomeLookAtZ" type="Single" />
20 <property name="Created" type="int" /> 20 <property name="Created" type="Int32" />
21 <property name="LastLogin" type="int" /> 21 <property name="LastLogin" type="Int32" />
22 <property name="RootInventoryFolderID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> 22 <property name="RootInventoryFolderID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
23 <property name="UserInventoryURI" type="String" length="255"/> 23 <property name="UserInventoryURI" type="String" length="255"/>
24 <property name="UserAssetURI" type="String" length="255"/> 24 <property name="UserAssetURI" type="String" length="255"/>