diff options
Diffstat (limited to 'OpenSim/Data/NHibernate/NHibernateInventoryData.cs')
-rw-r--r-- | OpenSim/Data/NHibernate/NHibernateInventoryData.cs | 42 |
1 files changed, 5 insertions, 37 deletions
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 | /***************************************************************** |