From e1140a4f9ba4b0d6b62002927dcde27d85a22ff0 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 12 Jun 2008 15:47:33 +0000 Subject: 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. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 84 +++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 34 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLAssetData.cs') 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 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 { -- cgit v1.1