From ec78a2871bedd951844be01490fcb85e22dac178 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 16 Jun 2008 14:10:51 +0000 Subject: the beginning of the great id format migration. This makes asset uuids no longer binary. I've tested this migration a few times, and it seems working in all the scenarios I've found but it wouldn't hurt to backup your asset db before running this as it does touch a very sensitive part of our content system. --- OpenSim/Data/Migration.cs | 2 ++ OpenSim/Data/MySQL/MySQLAssetData.cs | 10 ++++------ OpenSim/Data/MySQL/Resources/002_AssetStore.sql | 9 +++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/002_AssetStore.sql diff --git a/OpenSim/Data/Migration.cs b/OpenSim/Data/Migration.cs index d23200c..45b44b9 100644 --- a/OpenSim/Data/Migration.cs +++ b/OpenSim/Data/Migration.cs @@ -222,6 +222,8 @@ namespace OpenSim.Data { string[] names = _assem.GetManifestResourceNames(); SortedList migrations = new SortedList(); + // because life is funny if we don't + Array.Sort(names); foreach (string s in names) { diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index f51eee2..3cda5b8 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -125,8 +125,7 @@ namespace OpenSim.Data.MySQL new MySqlCommand( "SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", _dbConnection.Connection); - MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); - p.Value = assetID.GetBytes(); + cmd.Parameters.AddWithValue("?id", assetID.ToString()); try { @@ -180,8 +179,7 @@ namespace OpenSim.Data.MySQL { using (cmd) { - MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); - p.Value = asset.FullID.GetBytes(); + cmd.Parameters.AddWithValue("?id", asset.FullID.ToString()); cmd.Parameters.AddWithValue("?name", asset.Name); cmd.Parameters.AddWithValue("?description", asset.Description); cmd.Parameters.AddWithValue("?assetType", asset.Type); @@ -219,8 +217,8 @@ namespace OpenSim.Data.MySQL new MySqlCommand( "SELECT id FROM assets WHERE id=?id", _dbConnection.Connection); - MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16); - p.Value = uuid.GetBytes(); + + cmd.Parameters.AddWithValue("?id", uuid.ToString()); try { diff --git a/OpenSim/Data/MySQL/Resources/002_AssetStore.sql b/OpenSim/Data/MySQL/Resources/002_AssetStore.sql new file mode 100644 index 0000000..a7d7fca --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_AssetStore.sql @@ -0,0 +1,9 @@ +BEGIN; + +ALTER TABLE assets change id oldid binary(16); +ALTER TABLE assets add id varchar(36) not null default ''; +UPDATE assets set id = concat(substr(hex(oldid),1,8),"-",substr(hex(oldid),9,4),"-",substr(hex(oldid),13,4),"-",substr(hex(oldid),17,4),"-",substr(hex(oldid),21,12)); +ALTER TABLE assets drop oldid; +ALTER TABLE assets add constraint primary key(id); + +COMMIT; \ No newline at end of file -- cgit v1.1