diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index a2215ef94f..f51eee2d3a 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -42,6 +42,48 @@ namespace OpenSim.Data.MySQL
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
private void UpgradeAssetsTable(string oldVersion)
@@ -58,14 +100,20 @@ namespace OpenSim.Data.MySQL
///
/// Ensure that the assets related tables exists and are at the latest version
///
- private void TestTables()
+ private void TestTables(Migration m)
{
Dictionary tableList = new Dictionary();
tableList["assets"] = null;
_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)
@@ -208,38 +256,6 @@ namespace OpenSim.Data.MySQL
#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
{
diff --git a/OpenSim/Data/MySQL/MySQLDataStore.cs b/OpenSim/Data/MySQL/MySQLDataStore.cs
index a38a8b2468..60aca7a6ac 100644
--- a/OpenSim/Data/MySQL/MySQLDataStore.cs
+++ b/OpenSim/Data/MySQL/MySQLDataStore.cs
@@ -91,7 +91,16 @@ namespace OpenSim.Data.MySQL
m_log.Info("[REGION DB]: MySql - connecting: " + 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);
m_primDataAdapter = new MySqlDataAdapter(primSelectCmd);
@@ -112,8 +121,6 @@ namespace OpenSim.Data.MySQL
m_landAccessListDataAdapter = new MySqlDataAdapter(landAccessListSelectCmd);
- TestTables(m_connection);
-
lock (m_dataSet)
{
m_primTable = createPrimTable();
@@ -185,18 +192,18 @@ namespace OpenSim.Data.MySQL
}
}
}
- private void TestTablesVersionable(MySqlConnection dbconn)
- {
- Dictionary tableList = new Dictionary();
+ // private void TestTablesVersionable(MySqlConnection dbconn)
+ // {
+ // Dictionary tableList = new Dictionary();
- tableList["land"] = null;
- dbconn.Open();
- GetTableVersion(tableList,dbconn);
+ // tableList["land"] = null;
+ // dbconn.Open();
+ // GetTableVersion(tableList,dbconn);
- UpgradeLandTable(tableList["land"], dbconn);
- //database.Close();
+ // UpgradeLandTable(tableList["land"], dbconn);
+ // //database.Close();
- }
+ // }
///
/// Execute a SQL statement stored in a resource, as a string
@@ -1660,7 +1667,7 @@ namespace OpenSim.Data.MySQL
conn.Close();
}
- private bool TestTables(MySqlConnection conn)
+ private bool TestTables(MySqlConnection conn, Migration m)
{
MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn);
MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd);
@@ -1681,8 +1688,7 @@ namespace OpenSim.Data.MySQL
pDa.Fill(tmpDS, "prims");
sDa.Fill(tmpDS, "primshapes");
- if (persistPrimInventories)
- iDa.Fill(tmpDS, "primitems");
+ iDa.Fill(tmpDS, "primitems");
tDa.Fill(tmpDS, "terrain");
lDa.Fill(tmpDS, "land");
@@ -1691,67 +1697,73 @@ namespace OpenSim.Data.MySQL
catch (MySqlException)
{
m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating");
- InitDB(conn);
+ return false;
}
- 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;
- }
- }
+ // we have tables, but not a migration model yet
+ if (m.Version == 0)
+ m.Version = 1;
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;
}
/***********************************************************************
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index 8e160b7db4..1b86abf325 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -69,7 +69,16 @@ namespace OpenSim.Data.MySQL
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
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
@@ -107,7 +116,7 @@ namespace OpenSim.Data.MySQL
}
}
- private void TestTables(MySqlConnection conn)
+ private void TestTables(MySqlConnection conn, Migration m)
{
Dictionary tableList = new Dictionary();
@@ -115,11 +124,28 @@ namespace OpenSim.Data.MySQL
tableList["inventoryitems"] = null;
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"]);
UpgradeItemsTable(tableList["inventoryitems"]);
+
+ // ... and set the version
+ if (m.Version == 0)
+ m.Version = 1;
+
}
#endregion
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs
index f7176090e4..7d2da3a292 100644
--- a/OpenSim/Data/MySQL/MySQLUserData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserData.cs
@@ -105,7 +105,15 @@ namespace OpenSim.Data.MySQL
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
@@ -113,7 +121,7 @@ namespace OpenSim.Data.MySQL
///
/// Ensure that the user related tables exists and are at the latest version
///
- private void TestTables()
+ private void TestTables(Migration m)
{
Dictionary tableList = new Dictionary();
@@ -123,10 +131,30 @@ namespace OpenSim.Data.MySQL
tableList[m_appearanceTableName] = null;
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]);
UpgradeUsersTable(tableList[m_usersTableName]);
UpgradeFriendsTable(tableList[m_userFriendsTableName]);
UpgradeAppearanceTable(tableList[m_appearanceTableName]);
+
+ // ... and set the version
+ if (m.Version == 0)
+ m.Version = 1;
}
///