fix an edge case with migrations in the region store.

Add migration support to gridstore.
0.6.0-stable
Sean Dague 2008-06-19 15:03:00 +00:00
parent c2dc1636a6
commit fcd7cf5e4a
3 changed files with 54 additions and 2 deletions

View File

@ -1670,6 +1670,10 @@ namespace OpenSim.Data.MySQL
private bool TestTables(MySqlConnection conn, Migration m) private bool TestTables(MySqlConnection conn, Migration m)
{ {
// we already have migrations, get out of here
if (m.Version > 0)
return false;
MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn); MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, conn);
MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd); MySqlDataAdapter pDa = new MySqlDataAdapter(primSelectCmd);
MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, conn); MySqlCommand shapeSelectCmd = new MySqlCommand(m_shapeSelect, conn);

View File

@ -72,7 +72,15 @@ namespace OpenSim.Data.MySQL
settingPooling, settingPort); settingPooling, settingPort);
} }
TestTables(); // This actually does the roll forward assembly stuff
Assembly assem = GetType().Assembly;
Migration m = new Migration(database.Connection, assem, "GridStore");
// 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
@ -80,14 +88,22 @@ 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)
{ {
// we already have migrations, get out of here
if (m.Version > 0)
return;
Dictionary<string, string> tableList = new Dictionary<string, string>(); Dictionary<string, string> tableList = new Dictionary<string, string>();
tableList["regions"] = null; tableList["regions"] = null;
database.GetTableVersion(tableList); database.GetTableVersion(tableList);
UpgradeRegionsTable(tableList["regions"]); UpgradeRegionsTable(tableList["regions"]);
// we have tables, but not a migration model yet
if (m.Version == 0)
m.Version = 1;
} }
/// <summary> /// <summary>

View File

@ -0,0 +1,32 @@
CREATE TABLE `regions` (
`uuid` varchar(36) NOT NULL,
`regionHandle` bigint(20) unsigned NOT NULL,
`regionName` varchar(32) default NULL,
`regionRecvKey` varchar(128) default NULL,
`regionSendKey` varchar(128) default NULL,
`regionSecret` varchar(128) default NULL,
`regionDataURI` varchar(255) default NULL,
`serverIP` varchar(64) default NULL,
`serverPort` int(10) unsigned default NULL,
`serverURI` varchar(255) default NULL,
`locX` int(10) unsigned default NULL,
`locY` int(10) unsigned default NULL,
`locZ` int(10) unsigned default NULL,
`eastOverrideHandle` bigint(20) unsigned default NULL,
`westOverrideHandle` bigint(20) unsigned default NULL,
`southOverrideHandle` bigint(20) unsigned default NULL,
`northOverrideHandle` bigint(20) unsigned default NULL,
`regionAssetURI` varchar(255) default NULL,
`regionAssetRecvKey` varchar(128) default NULL,
`regionAssetSendKey` varchar(128) default NULL,
`regionUserURI` varchar(255) default NULL,
`regionUserRecvKey` varchar(128) default NULL,
`regionUserSendKey` varchar(128) default NULL, `regionMapTexture` varchar(36) default NULL,
`serverHttpPort` int(10) default NULL, `serverRemotingPort` int(10) default NULL,
`owner_uuid` varchar(36) default '00000000-0000-0000-0000-000000000000' not null,
`originUUID` varchar(36),
PRIMARY KEY (`uuid`),
KEY `regionName` (`regionName`),
KEY `regionHandle` (`regionHandle`),
KEY `overrideHandles` (`eastOverrideHandle`,`westOverrideHandle`,`southOverrideHandle`,`northOverrideHandle`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Rev. 3';