aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLDataStore.cs
diff options
context:
space:
mode:
authorSean Dague2008-06-12 15:47:33 +0000
committerSean Dague2008-06-12 15:47:33 +0000
commite1140a4f9ba4b0d6b62002927dcde27d85a22ff0 (patch)
treee1f010c1108afa1b424e0b065d9f743f07fed512 /OpenSim/Data/MySQL/MySQLDataStore.cs
parentcheck in region store initial migration definition, (diff)
downloadopensim-SC-e1140a4f9ba4b0d6b62002927dcde27d85a22ff0.zip
opensim-SC-e1140a4f9ba4b0d6b62002927dcde27d85a22ff0.tar.gz
opensim-SC-e1140a4f9ba4b0d6b62002927dcde27d85a22ff0.tar.bz2
opensim-SC-e1140a4f9ba4b0d6b62002927dcde27d85a22ff0.tar.xz
this, in theory, adds migration support to mysql for all
data sources besides the grid store. It is only lightly tested so the less adventurous should wait a couple of checkins before upgrading.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLDataStore.cs156
1 files changed, 84 insertions, 72 deletions
diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs
index a38a8b2..60aca7a 100644
--- a/OpenSim/Data/MySQL/MySQLDataStore.cs
+++ b/OpenSim/Data/MySQL/MySQLDataStore.cs
@@ -91,7 +91,16 @@ namespace OpenSim.Data.MySQL
91 m_log.Info("[REGION DB]: MySql - connecting: " + connectionstring); 91 m_log.Info("[REGION DB]: MySql - connecting: " + connectionstring);
92 m_connection = new MySqlConnection(connectionstring); 92 m_connection = new MySqlConnection(connectionstring);
93 93
94 TestTablesVersionable(m_connection); 94 // This actually does the roll forward assembly stuff
95 Assembly assem = GetType().Assembly;
96 Migration m = new Migration(m_connection, assem, "RegionStore");
97
98 // TODO: After rev 6000, remove this. People should have
99 // been rolled onto the new migration code by then.
100 TestTables(m_connection, m);
101
102 m.Update();
103
95 104
96 MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); 105 MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection);
97 m_primDataAdapter = new MySqlDataAdapter(primSelectCmd); 106 m_primDataAdapter = new MySqlDataAdapter(primSelectCmd);
@@ -112,8 +121,6 @@ namespace OpenSim.Data.MySQL
112 m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd); 121 m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd);
113 122
114 123
115 TestTables(m_connection);
116
117 lock (m_dataSet) 124 lock (m_dataSet)
118 { 125 {
119 m_primTable = createPrimTable(); 126 m_primTable = createPrimTable();
@@ -185,18 +192,18 @@ namespace OpenSim.Data.MySQL
185 } 192 }
186 } 193 }
187 } 194 }
188 private void TestTablesVersionable(MySqlConnection dbconn) 195 // private void TestTablesVersionable(MySqlConnection dbconn)
189 { 196 // {
190 Dictionary<string, string> tableList = new Dictionary<string, string>(); 197 // Dictionary<string, string> tableList = new Dictionary<string, string>();
191 198
192 tableList["land"] = null; 199 // tableList["land"] = null;
193 dbconn.Open(); 200 // dbconn.Open();
194 GetTableVersion(tableList,dbconn); 201 // GetTableVersion(tableList,dbconn);
195 202
196 UpgradeLandTable(tableList["land"], dbconn); 203 // UpgradeLandTable(tableList["land"], dbconn);
197 //database.Close(); 204 // //database.Close();
198 205
199 } 206 // }
200 207
201 /// <summary> 208 /// <summary>
202 /// Execute a SQL statement stored in a resource, as a string 209 /// Execute a SQL statement stored in a resource, as a string
@@ -1660,7 +1667,7 @@ namespace OpenSim.Data.MySQL
1660 conn.Close(); 1667 conn.Close();
1661 } 1668 }
1662 1669
1663 private bool TestTables(MySqlConnection conn) 1670 private bool TestTables(MySqlConnection conn, Migration m)
1664 { 1671 {
1665 MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn); 1672 MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn);
1666 MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd); 1673 MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd);
@@ -1681,8 +1688,7 @@ namespace OpenSim.Data.MySQL
1681 pDa.Fill(tmpDS, "prims"); 1688 pDa.Fill(tmpDS, "prims");
1682 sDa.Fill(tmpDS, "primshapes"); 1689 sDa.Fill(tmpDS, "primshapes");
1683 1690
1684 if (persistPrimInventories) 1691 iDa.Fill(tmpDS, "primitems");
1685 iDa.Fill(tmpDS, "primitems");
1686 1692
1687 tDa.Fill(tmpDS, "terrain"); 1693 tDa.Fill(tmpDS, "terrain");
1688 lDa.Fill(tmpDS, "land"); 1694 lDa.Fill(tmpDS, "land");
@@ -1691,67 +1697,73 @@ namespace OpenSim.Data.MySQL
1691 catch (MySqlException) 1697 catch (MySqlException)
1692 { 1698 {
1693 m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating"); 1699 m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating");
1694 InitDB(conn); 1700 return false;
1695 } 1701 }
1696 1702
1697 pDa.Fill(tmpDS, "prims"); 1703 // we have tables, but not a migration model yet
1698 sDa.Fill(tmpDS, "primshapes"); 1704 if (m.Version == 0)
1699 1705 m.Version = 1;
1700 if (persistPrimInventories)
1701 iDa.Fill(tmpDS, "primitems");
1702
1703 tDa.Fill(tmpDS, "terrain");
1704 lDa.Fill(tmpDS, "land");
1705 lalDa.Fill(tmpDS, "landaccesslist");
1706
1707 foreach (DataColumn col in createPrimTable().Columns)
1708 {
1709 if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName))
1710 {
1711 m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
1712 return false;
1713 }
1714 }
1715
1716 foreach (DataColumn col in createShapeTable().Columns)
1717 {
1718 if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName))
1719 {
1720 m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
1721 return false;
1722 }
1723 }
1724
1725 // XXX primitems should probably go here eventually
1726
1727 foreach (DataColumn col in createTerrainTable().Columns)
1728 {
1729 if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName))
1730 {
1731 m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName);
1732 return false;
1733 }
1734 }
1735
1736 foreach (DataColumn col in createLandTable().Columns)
1737 {
1738 if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName))
1739 {
1740 m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName);
1741 return false;
1742 }
1743 }
1744
1745 foreach (DataColumn col in createLandAccessListTable().Columns)
1746 {
1747 if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName))
1748 {
1749 m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName);
1750 return false;
1751 }
1752 }
1753 1706
1754 return true; 1707 return true;
1708
1709 // pDa.Fill(tmpDS, "prims");
1710 // sDa.Fill(tmpDS, "primshapes");
1711
1712 // if (persistPrimInventories)
1713 // iDa.Fill(tmpDS, "primitems");
1714
1715 // tDa.Fill(tmpDS, "terrain");
1716 // lDa.Fill(tmpDS, "land");
1717 // lalDa.Fill(tmpDS, "landaccesslist");
1718
1719 // foreach (DataColumn col in createPrimTable().Columns)
1720 // {
1721 // if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName))
1722 // {
1723 // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
1724 // return false;
1725 // }
1726 // }
1727
1728 // foreach (DataColumn col in createShapeTable().Columns)
1729 // {
1730 // if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName))
1731 // {
1732 // m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
1733 // return false;
1734 // }
1735 // }
1736
1737 // // XXX primitems should probably go here eventually
1738
1739 // foreach (DataColumn col in createTerrainTable().Columns)
1740 // {
1741 // if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName))
1742 // {
1743 // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName);
1744 // return false;
1745 // }
1746 // }
1747
1748 // foreach (DataColumn col in createLandTable().Columns)
1749 // {
1750 // if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName))
1751 // {
1752 // m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName);
1753 // return false;
1754 // }
1755 // }
1756
1757 // foreach (DataColumn col in createLandAccessListTable().Columns)
1758 // {
1759 // if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName))
1760 // {
1761 // m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName);
1762 // return false;
1763 // }
1764 // }
1765
1766 // return true;
1755 } 1767 }
1756 1768
1757 /*********************************************************************** 1769 /***********************************************************************