clean up the nhibernate definitions to work with mysql
integrate migration support into nhibernate0.6.0-stable
parent
b58dc7fb33
commit
6dea8f3435
|
@ -93,33 +93,6 @@ namespace OpenSim.Data.NHibernate
|
|||
Assembly assem = GetType().Assembly;
|
||||
Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore");
|
||||
m.Update();
|
||||
|
||||
}
|
||||
|
||||
private void InitDB()
|
||||
{
|
||||
string regex = @"no such table: Assets";
|
||||
Regex RE = new Regex(regex, RegexOptions.Multiline);
|
||||
try
|
||||
{
|
||||
using (ISession session = factory.OpenSession())
|
||||
{
|
||||
session.Load(typeof(AssetBase), LLUUID.Zero);
|
||||
}
|
||||
}
|
||||
catch (ObjectNotFoundException)
|
||||
{
|
||||
// yes, we know it's not there, but that's ok
|
||||
}
|
||||
catch (ADOException e)
|
||||
{
|
||||
Match m = RE.Match(e.ToString());
|
||||
if (m.Success)
|
||||
{
|
||||
// We don't have this table, so create it.
|
||||
new SchemaExport(cfg).Create(true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public AssetBase FetchAsset(LLUUID uuid)
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace OpenSim.Data.NHibernate
|
|||
// TODO: make this a real exception type
|
||||
throw new Exception("Malformed Inventory connection string '" + connect + "'");
|
||||
}
|
||||
string dialect = parts[0];
|
||||
|
||||
// Establish NHibernate Connection
|
||||
cfg = new Configuration();
|
||||
|
@ -74,46 +75,13 @@ namespace OpenSim.Data.NHibernate
|
|||
cfg.SetProperty(Environment.ConnectionString, parts[2]);
|
||||
cfg.AddAssembly("OpenSim.Data.NHibernate");
|
||||
|
||||
HbmSerializer.Default.Validate = true;
|
||||
using (MemoryStream stream =
|
||||
HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly()))
|
||||
cfg.AddInputStream(stream);
|
||||
|
||||
// If uncommented this will auto create tables, but it
|
||||
// does drops of the old tables, so we need a smarter way
|
||||
// to acturally manage this.
|
||||
|
||||
// new SchemaExport(cfg).Create(true, true);
|
||||
|
||||
factory = cfg.BuildSessionFactory();
|
||||
|
||||
InitDB();
|
||||
}
|
||||
// This actually does the roll forward assembly stuff
|
||||
Assembly assem = GetType().Assembly;
|
||||
Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore");
|
||||
m.Update();
|
||||
|
||||
private void InitDB()
|
||||
{
|
||||
string regex = @"no such table: Inventory";
|
||||
Regex RE = new Regex(regex, RegexOptions.Multiline);
|
||||
try
|
||||
{
|
||||
using (ISession session = factory.OpenSession())
|
||||
{
|
||||
session.Load(typeof(InventoryItemBase), LLUUID.Zero);
|
||||
}
|
||||
}
|
||||
catch (ObjectNotFoundException)
|
||||
{
|
||||
// yes, we know it's not there, but that's ok
|
||||
}
|
||||
catch (ADOException e)
|
||||
{
|
||||
Match m = RE.Match(e.ToString());
|
||||
if (m.Success)
|
||||
{
|
||||
// We don't have this table, so create it.
|
||||
new SchemaExport(cfg).Create(true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
|
|
|
@ -61,6 +61,7 @@ namespace OpenSim.Data.NHibernate
|
|||
// TODO: make this a real exception type
|
||||
throw new Exception("Malformed Inventory connection string '" + connect + "'");
|
||||
}
|
||||
string dialect = parts[0];
|
||||
|
||||
// This is stubbing for now, it will become dynamic later and support different db backends
|
||||
cfg = new Configuration();
|
||||
|
@ -73,41 +74,12 @@ namespace OpenSim.Data.NHibernate
|
|||
cfg.SetProperty(Environment.ConnectionString, parts[2]);
|
||||
cfg.AddAssembly("OpenSim.Data.NHibernate");
|
||||
|
||||
HbmSerializer.Default.Validate = true;
|
||||
using (MemoryStream stream =
|
||||
HbmSerializer.Default.Serialize(Assembly.GetExecutingAssembly()))
|
||||
cfg.AddInputStream(stream);
|
||||
|
||||
// new SchemaExport(cfg).Create(true, true);
|
||||
|
||||
factory = cfg.BuildSessionFactory();
|
||||
InitDB();
|
||||
}
|
||||
|
||||
private void InitDB()
|
||||
{
|
||||
string regex = @"no such table: UserProfiles";
|
||||
Regex RE = new Regex(regex, RegexOptions.Multiline);
|
||||
try
|
||||
{
|
||||
using (ISession session = factory.OpenSession())
|
||||
{
|
||||
session.Load(typeof(UserProfileData), LLUUID.Zero);
|
||||
}
|
||||
}
|
||||
catch (ObjectNotFoundException)
|
||||
{
|
||||
// yes, we know it's not there, but that's ok
|
||||
}
|
||||
catch (ADOException e)
|
||||
{
|
||||
Match m = RE.Match(e.ToString());
|
||||
if (m.Success)
|
||||
{
|
||||
// We don't have this table, so create it.
|
||||
new SchemaExport(cfg).Create(true, true);
|
||||
}
|
||||
}
|
||||
// This actually does the roll forward assembly stuff
|
||||
Assembly assem = GetType().Assembly;
|
||||
Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore");
|
||||
m.Update();
|
||||
}
|
||||
|
||||
private bool ExistsUser(LLUUID uuid)
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
<id name="FullID" column="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate">
|
||||
<generator class="assigned" />
|
||||
</id>
|
||||
<property name="Type" type="SByte" />
|
||||
<property name="InvType" type="SByte" />
|
||||
<property name="Name" type="String" length="50" />
|
||||
<property name="Description" type="String" length="50" />
|
||||
<property name="Type" type="Int16" />
|
||||
<property name="InvType" type="Int16" />
|
||||
<property name="Name" type="String" length="64" />
|
||||
<property name="Description" type="String" length="64" />
|
||||
<property name="Local" type="boolean" />
|
||||
<property name="Temporary" type="boolean" />
|
||||
<property name="Data" type="binary" />
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
<id name="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate">
|
||||
<generator class="assigned" />
|
||||
</id>
|
||||
<property name="Type" type="short" />
|
||||
<property name="Version" type="UInt16" />
|
||||
<property name="Type" type="Int32" />
|
||||
<property name="Version" type="Int32" />
|
||||
<property name="ParentID" index="folder_parent_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||
<property name="Owner" index="folder_owner_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||
<property name="Name" type="String" length="64" />
|
||||
|
|
|
@ -4,23 +4,23 @@
|
|||
<id name="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate">
|
||||
<generator class="assigned" />
|
||||
</id>
|
||||
<property name="InvType" type="int" />
|
||||
<property name="AssetType" type="int" />
|
||||
<property name="InvType" type="Int16" />
|
||||
<property name="AssetType" type="Int16" />
|
||||
<property name="AssetID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||
<property name="Folder" index="item_folder_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||
<property name="Owner" index="item_owner_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||
<property name="Creator" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||
<property name="Name" type="String" length="64" />
|
||||
<property name="Description" type="String" length="64" />
|
||||
<property name="NextPermissions" type="UInt32" />
|
||||
<property name="CurrentPermissions" type="UInt32" />
|
||||
<property name="BasePermissions" type="UInt32" />
|
||||
<property name="EveryOnePermissions" type="UInt32" />
|
||||
<property name="NextPermissions" type="Int32" />
|
||||
<property name="CurrentPermissions" type="Int32" />
|
||||
<property name="BasePermissions" type="Int32" />
|
||||
<property name="EveryOnePermissions" type="Int32" />
|
||||
<property name="GroupID" index="item_group_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||
<property name="GroupOwned" type="boolean" />
|
||||
<property name="SalePrice" type="Int32" />
|
||||
<property name="SaleType" type="Byte" />
|
||||
<property name="Flags" type="UInt32" />
|
||||
<property name="SaleType" type="Int16" />
|
||||
<property name="Flags" type="Int32" />
|
||||
<property name="CreationDate" type="Int32" />
|
||||
</class>
|
||||
</hibernate-mapping>
|
|
@ -5,7 +5,7 @@
|
|||
<generator class="assigned" />
|
||||
</id>
|
||||
<property name="AgentIP" type="String" length="24" />
|
||||
<property name="AgentPort" type="UInt32" />
|
||||
<property name="AgentPort" type="Int32" />
|
||||
<property name="AgentOnline" type="boolean" />
|
||||
<property name="SessionID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||
<property name="SecureSessionID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||
|
@ -13,7 +13,7 @@
|
|||
<property name="Region" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||
<property name="LoginTime" type="Int32" />
|
||||
<property name="LogoutTime" type="Int32" />
|
||||
<property name="Handle" type="UInt64" />
|
||||
<property name="Handle" type="Int64" />
|
||||
<property name="PositionX" type="Single" />
|
||||
<property name="PositionY" type="Single" />
|
||||
<property name="PositionZ" type="Single" />
|
||||
|
|
|
@ -9,16 +9,16 @@
|
|||
<property name="PasswordHash" type="String" length="32" />
|
||||
<property name="PasswordSalt" type="String" length="32" />
|
||||
<property name="WebLoginKey" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||
<property name="HomeRegionX" type="UInt32" />
|
||||
<property name="HomeRegionY" type="UInt32" />
|
||||
<property name="HomeRegionX" type="Int32" />
|
||||
<property name="HomeRegionY" type="Int32" />
|
||||
<property name="HomeLocationX" type="Single" />
|
||||
<property name="HomeLocationY" type="Single" />
|
||||
<property name="HomeLocationZ" type="Single" />
|
||||
<property name="HomeLookAtX" type="Single" />
|
||||
<property name="HomeLookAtY" type="Single" />
|
||||
<property name="HomeLookAtZ" type="Single" />
|
||||
<property name="Created" type="int" />
|
||||
<property name="LastLogin" type="int" />
|
||||
<property name="Created" type="Int32" />
|
||||
<property name="LastLogin" type="Int32" />
|
||||
<property name="RootInventoryFolderID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||
<property name="UserInventoryURI" type="String" length="255"/>
|
||||
<property name="UserAssetURI" type="String" length="255"/>
|
||||
|
|
Loading…
Reference in New Issue