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.0.6.0-stable
parent
cee071ea60
commit
e1140a4f9b
|
@ -42,6 +42,48 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
private MySQLManager _dbConnection;
|
private MySQLManager _dbConnection;
|
||||||
|
|
||||||
|
#region IPlugin Members
|
||||||
|
|
||||||
|
override public void Initialise(string connect)
|
||||||
|
{
|
||||||
|
// TODO: This will let you pass in the connect string in
|
||||||
|
// the config, though someone will need to write that.
|
||||||
|
if (connect == String.Empty)
|
||||||
|
{
|
||||||
|
// This is old seperate config file
|
||||||
|
m_log.Warn("no connect string, using old mysql_connection.ini instead");
|
||||||
|
Initialise();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_dbConnection = new MySQLManager(connect);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This actually does the roll forward assembly stuff
|
||||||
|
Assembly assem = GetType().Assembly;
|
||||||
|
Migration m = new Migration(_dbConnection.Connection, assem, "AssetStore");
|
||||||
|
|
||||||
|
// TODO: After rev 6000, remove this. People should have
|
||||||
|
// been rolled onto the new migration code by then.
|
||||||
|
TestTables(m);
|
||||||
|
|
||||||
|
m.Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
override public void Initialise()
|
||||||
|
{
|
||||||
|
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
||||||
|
string hostname = GridDataMySqlFile.ParseFileReadValue("hostname");
|
||||||
|
string database = GridDataMySqlFile.ParseFileReadValue("database");
|
||||||
|
string username = GridDataMySqlFile.ParseFileReadValue("username");
|
||||||
|
string password = GridDataMySqlFile.ParseFileReadValue("password");
|
||||||
|
string pooling = GridDataMySqlFile.ParseFileReadValue("pooling");
|
||||||
|
string port = GridDataMySqlFile.ParseFileReadValue("port");
|
||||||
|
|
||||||
|
_dbConnection = new MySQLManager(hostname, database, username, password, pooling, port);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#region IAssetProvider Members
|
#region IAssetProvider Members
|
||||||
|
|
||||||
private void UpgradeAssetsTable(string oldVersion)
|
private void UpgradeAssetsTable(string oldVersion)
|
||||||
|
@ -58,14 +100,20 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ensure that the assets related tables exists and are at the latest version
|
/// Ensure that the assets related tables exists and are at the latest version
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void TestTables()
|
private void TestTables(Migration m)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
||||||
|
|
||||||
tableList["assets"] = null;
|
tableList["assets"] = null;
|
||||||
_dbConnection.GetTableVersion(tableList);
|
_dbConnection.GetTableVersion(tableList);
|
||||||
|
|
||||||
UpgradeAssetsTable(tableList["assets"]);
|
// if there is no table, return, migrations will handle it.
|
||||||
|
if (tableList["assets"] == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// if there is a table, and we don't have a migration, set it to 1
|
||||||
|
if (m.Version == 0)
|
||||||
|
m.Version = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
override public AssetBase FetchAsset(LLUUID assetID)
|
override public AssetBase FetchAsset(LLUUID assetID)
|
||||||
|
@ -208,38 +256,6 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IPlugin Members
|
|
||||||
|
|
||||||
override public void Initialise(string connect)
|
|
||||||
{
|
|
||||||
// TODO: This will let you pass in the connect string in
|
|
||||||
// the config, though someone will need to write that.
|
|
||||||
if (connect == String.Empty)
|
|
||||||
{
|
|
||||||
// This is old seperate config file
|
|
||||||
Initialise();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_dbConnection = new MySQLManager(connect);
|
|
||||||
TestTables();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override public void Initialise()
|
|
||||||
{
|
|
||||||
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
|
|
||||||
string hostname = GridDataMySqlFile.ParseFileReadValue("hostname");
|
|
||||||
string database = GridDataMySqlFile.ParseFileReadValue("database");
|
|
||||||
string username = GridDataMySqlFile.ParseFileReadValue("username");
|
|
||||||
string password = GridDataMySqlFile.ParseFileReadValue("password");
|
|
||||||
string pooling = GridDataMySqlFile.ParseFileReadValue("pooling");
|
|
||||||
string port = GridDataMySqlFile.ParseFileReadValue("port");
|
|
||||||
|
|
||||||
_dbConnection = new MySQLManager(hostname, database, username, password, pooling, port);
|
|
||||||
|
|
||||||
TestTables();
|
|
||||||
}
|
|
||||||
|
|
||||||
override public string Version
|
override public string Version
|
||||||
{
|
{
|
||||||
|
|
|
@ -91,7 +91,16 @@ namespace OpenSim.Data.MySQL
|
||||||
m_log.Info("[REGION DB]: MySql - connecting: " + connectionstring);
|
m_log.Info("[REGION DB]: MySql - connecting: " + connectionstring);
|
||||||
m_connection = new MySqlConnection(connectionstring);
|
m_connection = new MySqlConnection(connectionstring);
|
||||||
|
|
||||||
TestTablesVersionable(m_connection);
|
// This actually does the roll forward assembly stuff
|
||||||
|
Assembly assem = GetType().Assembly;
|
||||||
|
Migration m = new Migration(m_connection, assem, "RegionStore");
|
||||||
|
|
||||||
|
// TODO: After rev 6000, remove this. People should have
|
||||||
|
// been rolled onto the new migration code by then.
|
||||||
|
TestTables(m_connection, m);
|
||||||
|
|
||||||
|
m.Update();
|
||||||
|
|
||||||
|
|
||||||
MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection);
|
MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection);
|
||||||
m_primDataAdapter = new MySqlDataAdapter(primSelectCmd);
|
m_primDataAdapter = new MySqlDataAdapter(primSelectCmd);
|
||||||
|
@ -112,8 +121,6 @@ namespace OpenSim.Data.MySQL
|
||||||
m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd);
|
m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd);
|
||||||
|
|
||||||
|
|
||||||
TestTables(m_connection);
|
|
||||||
|
|
||||||
lock (m_dataSet)
|
lock (m_dataSet)
|
||||||
{
|
{
|
||||||
m_primTable = createPrimTable();
|
m_primTable = createPrimTable();
|
||||||
|
@ -185,18 +192,18 @@ namespace OpenSim.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void TestTablesVersionable(MySqlConnection dbconn)
|
// private void TestTablesVersionable(MySqlConnection dbconn)
|
||||||
{
|
// {
|
||||||
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
// Dictionary<string, string> tableList = new Dictionary<string, string>();
|
||||||
|
|
||||||
tableList["land"] = null;
|
// tableList["land"] = null;
|
||||||
dbconn.Open();
|
// dbconn.Open();
|
||||||
GetTableVersion(tableList,dbconn);
|
// GetTableVersion(tableList,dbconn);
|
||||||
|
|
||||||
UpgradeLandTable(tableList["land"], dbconn);
|
// UpgradeLandTable(tableList["land"], dbconn);
|
||||||
//database.Close();
|
// //database.Close();
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute a SQL statement stored in a resource, as a string
|
/// Execute a SQL statement stored in a resource, as a string
|
||||||
|
@ -1660,7 +1667,7 @@ namespace OpenSim.Data.MySQL
|
||||||
conn.Close();
|
conn.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TestTables(MySqlConnection conn)
|
private bool TestTables(MySqlConnection conn, Migration m)
|
||||||
{
|
{
|
||||||
MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn);
|
MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn);
|
||||||
MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd);
|
MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd);
|
||||||
|
@ -1681,8 +1688,7 @@ namespace OpenSim.Data.MySQL
|
||||||
pDa.Fill(tmpDS, "prims");
|
pDa.Fill(tmpDS, "prims");
|
||||||
sDa.Fill(tmpDS, "primshapes");
|
sDa.Fill(tmpDS, "primshapes");
|
||||||
|
|
||||||
if (persistPrimInventories)
|
iDa.Fill(tmpDS, "primitems");
|
||||||
iDa.Fill(tmpDS, "primitems");
|
|
||||||
|
|
||||||
tDa.Fill(tmpDS, "terrain");
|
tDa.Fill(tmpDS, "terrain");
|
||||||
lDa.Fill(tmpDS, "land");
|
lDa.Fill(tmpDS, "land");
|
||||||
|
@ -1691,67 +1697,73 @@ namespace OpenSim.Data.MySQL
|
||||||
catch (MySqlException)
|
catch (MySqlException)
|
||||||
{
|
{
|
||||||
m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating");
|
m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating");
|
||||||
InitDB(conn);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pDa.Fill(tmpDS, "prims");
|
// we have tables, but not a migration model yet
|
||||||
sDa.Fill(tmpDS, "primshapes");
|
if (m.Version == 0)
|
||||||
|
m.Version = 1;
|
||||||
if (persistPrimInventories)
|
|
||||||
iDa.Fill(tmpDS, "primitems");
|
|
||||||
|
|
||||||
tDa.Fill(tmpDS, "terrain");
|
|
||||||
lDa.Fill(tmpDS, "land");
|
|
||||||
lalDa.Fill(tmpDS, "landaccesslist");
|
|
||||||
|
|
||||||
foreach (DataColumn col in createPrimTable().Columns)
|
|
||||||
{
|
|
||||||
if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName))
|
|
||||||
{
|
|
||||||
m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (DataColumn col in createShapeTable().Columns)
|
|
||||||
{
|
|
||||||
if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName))
|
|
||||||
{
|
|
||||||
m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX primitems should probably go here eventually
|
|
||||||
|
|
||||||
foreach (DataColumn col in createTerrainTable().Columns)
|
|
||||||
{
|
|
||||||
if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName))
|
|
||||||
{
|
|
||||||
m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (DataColumn col in createLandTable().Columns)
|
|
||||||
{
|
|
||||||
if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName))
|
|
||||||
{
|
|
||||||
m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (DataColumn col in createLandAccessListTable().Columns)
|
|
||||||
{
|
|
||||||
if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName))
|
|
||||||
{
|
|
||||||
m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// pDa.Fill(tmpDS, "prims");
|
||||||
|
// sDa.Fill(tmpDS, "primshapes");
|
||||||
|
|
||||||
|
// if (persistPrimInventories)
|
||||||
|
// iDa.Fill(tmpDS, "primitems");
|
||||||
|
|
||||||
|
// tDa.Fill(tmpDS, "terrain");
|
||||||
|
// lDa.Fill(tmpDS, "land");
|
||||||
|
// lalDa.Fill(tmpDS, "landaccesslist");
|
||||||
|
|
||||||
|
// foreach (DataColumn col in createPrimTable().Columns)
|
||||||
|
// {
|
||||||
|
// if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName))
|
||||||
|
// {
|
||||||
|
// m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// foreach (DataColumn col in createShapeTable().Columns)
|
||||||
|
// {
|
||||||
|
// if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName))
|
||||||
|
// {
|
||||||
|
// m_log.Info("[REGION DB]: Missing required column:" + col.ColumnName);
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // XXX primitems should probably go here eventually
|
||||||
|
|
||||||
|
// foreach (DataColumn col in createTerrainTable().Columns)
|
||||||
|
// {
|
||||||
|
// if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName))
|
||||||
|
// {
|
||||||
|
// m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName);
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// foreach (DataColumn col in createLandTable().Columns)
|
||||||
|
// {
|
||||||
|
// if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName))
|
||||||
|
// {
|
||||||
|
// m_log.Info("[REGION DB]: Missing require column:" + col.ColumnName);
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// foreach (DataColumn col in createLandAccessListTable().Columns)
|
||||||
|
// {
|
||||||
|
// if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName))
|
||||||
|
// {
|
||||||
|
// m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName);
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
|
|
@ -69,7 +69,16 @@ namespace OpenSim.Data.MySQL
|
||||||
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
|
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
|
||||||
settingPort);
|
settingPort);
|
||||||
}
|
}
|
||||||
TestTables(database.Connection);
|
|
||||||
|
// This actually does the roll forward assembly stuff
|
||||||
|
Assembly assem = GetType().Assembly;
|
||||||
|
Migration m = new Migration(database.Connection, assem, "AssetStore");
|
||||||
|
|
||||||
|
// TODO: After rev 6000, remove this. People should have
|
||||||
|
// been rolled onto the new migration code by then.
|
||||||
|
TestTables(database.Connection, m);
|
||||||
|
|
||||||
|
m.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Test and initialization code
|
#region Test and initialization code
|
||||||
|
@ -107,7 +116,7 @@ namespace OpenSim.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TestTables(MySqlConnection conn)
|
private void TestTables(MySqlConnection conn, Migration m)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
@ -115,11 +124,28 @@ namespace OpenSim.Data.MySQL
|
||||||
tableList["inventoryitems"] = null;
|
tableList["inventoryitems"] = null;
|
||||||
|
|
||||||
database.GetTableVersion(tableList);
|
database.GetTableVersion(tableList);
|
||||||
m_log.Info("[INVENTORY DB]: Inventory Folder Version: " + tableList["inventoryfolders"]);
|
|
||||||
m_log.Info("[INVENTORY DB]: Inventory Items Version: " + tableList["inventoryitems"]);
|
|
||||||
|
|
||||||
|
// if we've already started using migrations, get out of
|
||||||
|
// here, we've got this under control
|
||||||
|
if (m.Version > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// if there are no tables, get out of here and let
|
||||||
|
// migrations do their job
|
||||||
|
if(
|
||||||
|
tableList["inventoryfolders"] == null &&
|
||||||
|
tableList["inventoryitems"] == null
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// otherwise, let the upgrade on legacy proceed...
|
||||||
UpgradeFoldersTable(tableList["inventoryfolders"]);
|
UpgradeFoldersTable(tableList["inventoryfolders"]);
|
||||||
UpgradeItemsTable(tableList["inventoryitems"]);
|
UpgradeItemsTable(tableList["inventoryitems"]);
|
||||||
|
|
||||||
|
// ... and set the version
|
||||||
|
if (m.Version == 0)
|
||||||
|
m.Version = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -105,7 +105,15 @@ namespace OpenSim.Data.MySQL
|
||||||
database = new MySQLManager(m_connectString);
|
database = new MySQLManager(m_connectString);
|
||||||
}
|
}
|
||||||
|
|
||||||
TestTables();
|
// This actually does the roll forward assembly stuff
|
||||||
|
Assembly assem = GetType().Assembly;
|
||||||
|
Migration m = new Migration(database.Connection, assem, "AssetStore");
|
||||||
|
|
||||||
|
// TODO: After rev 6000, remove this. People should have
|
||||||
|
// been rolled onto the new migration code by then.
|
||||||
|
TestTables(m);
|
||||||
|
|
||||||
|
m.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Test and initialization code
|
#region Test and initialization code
|
||||||
|
@ -113,7 +121,7 @@ namespace OpenSim.Data.MySQL
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ensure that the user related tables exists and are at the latest version
|
/// Ensure that the user related tables exists and are at the latest version
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void TestTables()
|
private void TestTables(Migration m)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
Dictionary<string, string> tableList = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
@ -123,10 +131,30 @@ namespace OpenSim.Data.MySQL
|
||||||
tableList[m_appearanceTableName] = null;
|
tableList[m_appearanceTableName] = null;
|
||||||
database.GetTableVersion(tableList);
|
database.GetTableVersion(tableList);
|
||||||
|
|
||||||
|
// if we've already started using migrations, get out of
|
||||||
|
// here, we've got this under control
|
||||||
|
if (m.Version > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// if there are no tables, get out of here and let
|
||||||
|
// migrations do their job
|
||||||
|
if(
|
||||||
|
tableList[m_agentsTableName] == null &&
|
||||||
|
tableList[m_usersTableName] == null &&
|
||||||
|
tableList[m_userFriendsTableName] == null &&
|
||||||
|
tableList[m_appearanceTableName] == null
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// otherwise, let the upgrade on legacy proceed...
|
||||||
UpgradeAgentsTable(tableList[m_agentsTableName]);
|
UpgradeAgentsTable(tableList[m_agentsTableName]);
|
||||||
UpgradeUsersTable(tableList[m_usersTableName]);
|
UpgradeUsersTable(tableList[m_usersTableName]);
|
||||||
UpgradeFriendsTable(tableList[m_userFriendsTableName]);
|
UpgradeFriendsTable(tableList[m_userFriendsTableName]);
|
||||||
UpgradeAppearanceTable(tableList[m_appearanceTableName]);
|
UpgradeAppearanceTable(tableList[m_appearanceTableName]);
|
||||||
|
|
||||||
|
// ... and set the version
|
||||||
|
if (m.Version == 0)
|
||||||
|
m.Version = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue