aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
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
parentcheck in region store initial migration definition, (diff)
downloadopensim-SC_OLD-e1140a4f9ba4b0d6b62002927dcde27d85a22ff0.zip
opensim-SC_OLD-e1140a4f9ba4b0d6b62002927dcde27d85a22ff0.tar.gz
opensim-SC_OLD-e1140a4f9ba4b0d6b62002927dcde27d85a22ff0.tar.bz2
opensim-SC_OLD-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 'OpenSim')
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs84
-rw-r--r--OpenSim/Data/MySQL/MySQLDataStore.cs156
-rw-r--r--OpenSim/Data/MySQL/MySQLInventoryData.cs34
-rw-r--r--OpenSim/Data/MySQL/MySQLUserData.cs32
4 files changed, 194 insertions, 112 deletions
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index a2215ef..f51eee2 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -42,6 +42,48 @@ namespace OpenSim.Data.MySQL
42 42
43 private MySQLManager _dbConnection; 43 private MySQLManager _dbConnection;
44 44
45 #region IPlugin Members
46
47 override public void Initialise(string connect)
48 {
49 // TODO: This will let you pass in the connect string in
50 // the config, though someone will need to write that.
51 if (connect == String.Empty)
52 {
53 // This is old seperate config file
54 m_log.Warn("no connect string, using old mysql_connection.ini instead");
55 Initialise();
56 }
57 else
58 {
59 _dbConnection = new MySQLManager(connect);
60 }
61
62 // This actually does the roll forward assembly stuff
63 Assembly assem = GetType().Assembly;
64 Migration m = new Migration(_dbConnection.Connection, assem, "AssetStore");
65
66 // TODO: After rev 6000, remove this. People should have
67 // been rolled onto the new migration code by then.
68 TestTables(m);
69
70 m.Update();
71 }
72
73 override public void Initialise()
74 {
75 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
76 string hostname = GridDataMySqlFile.ParseFileReadValue("hostname");
77 string database = GridDataMySqlFile.ParseFileReadValue("database");
78 string username = GridDataMySqlFile.ParseFileReadValue("username");
79 string password = GridDataMySqlFile.ParseFileReadValue("password");
80 string pooling = GridDataMySqlFile.ParseFileReadValue("pooling");
81 string port = GridDataMySqlFile.ParseFileReadValue("port");
82
83 _dbConnection = new MySQLManager(hostname, database, username, password, pooling, port);
84
85 }
86
45 #region IAssetProvider Members 87 #region IAssetProvider Members
46 88
47 private void UpgradeAssetsTable(string oldVersion) 89 private void UpgradeAssetsTable(string oldVersion)
@@ -58,14 +100,20 @@ namespace OpenSim.Data.MySQL
58 /// <summary> 100 /// <summary>
59 /// Ensure that the assets related tables exists and are at the latest version 101 /// Ensure that the assets related tables exists and are at the latest version
60 /// </summary> 102 /// </summary>
61 private void TestTables() 103 private void TestTables(Migration m)
62 { 104 {
63 Dictionary<string, string> tableList = new Dictionary<string, string>(); 105 Dictionary<string, string> tableList = new Dictionary<string, string>();
64 106
65 tableList["assets"] = null; 107 tableList["assets"] = null;
66 _dbConnection.GetTableVersion(tableList); 108 _dbConnection.GetTableVersion(tableList);
67 109
68 UpgradeAssetsTable(tableList["assets"]); 110 // if there is no table, return, migrations will handle it.
111 if (tableList["assets"] == null)
112 return;
113
114 // if there is a table, and we don't have a migration, set it to 1
115 if (m.Version == 0)
116 m.Version = 1;
69 } 117 }
70 118
71 override public AssetBase FetchAsset(LLUUID assetID) 119 override public AssetBase FetchAsset(LLUUID assetID)
@@ -208,38 +256,6 @@ namespace OpenSim.Data.MySQL
208 256
209 #endregion 257 #endregion
210 258
211 #region IPlugin Members
212
213 override public void Initialise(string connect)
214 {
215 // TODO: This will let you pass in the connect string in
216 // the config, though someone will need to write that.
217 if (connect == String.Empty)
218 {
219 // This is old seperate config file
220 Initialise();
221 }
222 else
223 {
224 _dbConnection = new MySQLManager(connect);
225 TestTables();
226 }
227 }
228
229 override public void Initialise()
230 {
231 IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
232 string hostname = GridDataMySqlFile.ParseFileReadValue("hostname");
233 string database = GridDataMySqlFile.ParseFileReadValue("database");
234 string username = GridDataMySqlFile.ParseFileReadValue("username");
235 string password = GridDataMySqlFile.ParseFileReadValue("password");
236 string pooling = GridDataMySqlFile.ParseFileReadValue("pooling");
237 string port = GridDataMySqlFile.ParseFileReadValue("port");
238
239 _dbConnection = new MySQLManager(hostname, database, username, password, pooling, port);
240
241 TestTables();
242 }
243 259
244 override public string Version 260 override public string Version
245 { 261 {
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 /***********************************************************************
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index 8e160b7..1b86abf 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -69,7 +69,16 @@ namespace OpenSim.Data.MySQL
69 new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, 69 new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
70 settingPort); 70 settingPort);
71 } 71 }
72 TestTables(database.Connection); 72
73 // This actually does the roll forward assembly stuff
74 Assembly assem = GetType().Assembly;
75 Migration m = new Migration(database.Connection, assem, "AssetStore");
76
77 // TODO: After rev 6000, remove this. People should have
78 // been rolled onto the new migration code by then.
79 TestTables(database.Connection, m);
80
81 m.Update();
73 } 82 }
74 83
75 #region Test and initialization code 84 #region Test and initialization code
@@ -107,7 +116,7 @@ namespace OpenSim.Data.MySQL
107 } 116 }
108 } 117 }
109 118
110 private void TestTables(MySqlConnection conn) 119 private void TestTables(MySqlConnection conn, Migration m)
111 { 120 {
112 Dictionary<string, string> tableList = new Dictionary<string, string>(); 121 Dictionary<string, string> tableList = new Dictionary<string, string>();
113 122
@@ -115,11 +124,28 @@ namespace OpenSim.Data.MySQL
115 tableList["inventoryitems"] = null; 124 tableList["inventoryitems"] = null;
116 125
117 database.GetTableVersion(tableList); 126 database.GetTableVersion(tableList);
118 m_log.Info("[INVENTORY DB]: Inventory Folder Version: " + tableList["inventoryfolders"]);
119 m_log.Info("[INVENTORY DB]: Inventory Items Version: " + tableList["inventoryitems"]);
120 127
128 // if we've already started using migrations, get out of
129 // here, we've got this under control
130 if (m.Version > 0)
131 return;
132
133 // if there are no tables, get out of here and let
134 // migrations do their job
135 if(
136 tableList["inventoryfolders"] == null &&
137 tableList["inventoryitems"] == null
138 )
139 return;
140
141 // otherwise, let the upgrade on legacy proceed...
121 UpgradeFoldersTable(tableList["inventoryfolders"]); 142 UpgradeFoldersTable(tableList["inventoryfolders"]);
122 UpgradeItemsTable(tableList["inventoryitems"]); 143 UpgradeItemsTable(tableList["inventoryitems"]);
144
145 // ... and set the version
146 if (m.Version == 0)
147 m.Version = 1;
148
123 } 149 }
124 150
125 #endregion 151 #endregion
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs
index f717609..7d2da3a 100644
--- a/OpenSim/Data/MySQL/MySQLUserData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserData.cs
@@ -105,7 +105,15 @@ namespace OpenSim.Data.MySQL
105 database = new MySQLManager(m_connectString); 105 database = new MySQLManager(m_connectString);
106 } 106 }
107 107
108 TestTables(); 108 // This actually does the roll forward assembly stuff
109 Assembly assem = GetType().Assembly;
110 Migration m = new Migration(database.Connection, assem, "AssetStore");
111
112 // TODO: After rev 6000, remove this. People should have
113 // been rolled onto the new migration code by then.
114 TestTables(m);
115
116 m.Update();
109 } 117 }
110 118
111 #region Test and initialization code 119 #region Test and initialization code
@@ -113,7 +121,7 @@ namespace OpenSim.Data.MySQL
113 /// <summary> 121 /// <summary>
114 /// Ensure that the user related tables exists and are at the latest version 122 /// Ensure that the user related tables exists and are at the latest version
115 /// </summary> 123 /// </summary>
116 private void TestTables() 124 private void TestTables(Migration m)
117 { 125 {
118 Dictionary<string, string> tableList = new Dictionary<string, string>(); 126 Dictionary<string, string> tableList = new Dictionary<string, string>();
119 127
@@ -123,10 +131,30 @@ namespace OpenSim.Data.MySQL
123 tableList[m_appearanceTableName] = null; 131 tableList[m_appearanceTableName] = null;
124 database.GetTableVersion(tableList); 132 database.GetTableVersion(tableList);
125 133
134 // if we've already started using migrations, get out of
135 // here, we've got this under control
136 if (m.Version > 0)
137 return;
138
139 // if there are no tables, get out of here and let
140 // migrations do their job
141 if(
142 tableList[m_agentsTableName] == null &&
143 tableList[m_usersTableName] == null &&
144 tableList[m_userFriendsTableName] == null &&
145 tableList[m_appearanceTableName] == null
146 )
147 return;
148
149 // otherwise, let the upgrade on legacy proceed...
126 UpgradeAgentsTable(tableList[m_agentsTableName]); 150 UpgradeAgentsTable(tableList[m_agentsTableName]);
127 UpgradeUsersTable(tableList[m_usersTableName]); 151 UpgradeUsersTable(tableList[m_usersTableName]);
128 UpgradeFriendsTable(tableList[m_userFriendsTableName]); 152 UpgradeFriendsTable(tableList[m_userFriendsTableName]);
129 UpgradeAppearanceTable(tableList[m_appearanceTableName]); 153 UpgradeAppearanceTable(tableList[m_appearanceTableName]);
154
155 // ... and set the version
156 if (m.Version == 0)
157 m.Version = 1;
130 } 158 }
131 159
132 /// <summary> 160 /// <summary>