From 9052c43319ab69f57b80e363d965780be625b0e2 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Wed, 2 Jul 2008 16:20:54 +0000
Subject: * Drop InvType from the assets table since it is no longer used *
Migration should be automatic on sqlite and mysql * Migration is not
automatic on mssql, you will need to drop the invType column manually *
Migration should be fine, but as for any db change, I would recommend making
sure you have backups before moving past this revision
---
OpenSim/Data/MSSQL/MSSQLAssetData.cs | 10 +++-------
OpenSim/Data/MSSQL/MSSQLManager.cs | 1 -
OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql | 1 -
OpenSim/Data/MySQL/MySQLAssetData.cs | 8 +++-----
OpenSim/Data/MySQL/Resources/004_AssetStore.sql | 5 +++++
OpenSim/Data/SQLite/Resources/002_AssetStore.sql | 10 ++++++++++
OpenSim/Data/SQLite/SQLiteAssetData.cs | 12 ++++--------
7 files changed, 25 insertions(+), 22 deletions(-)
create mode 100644 OpenSim/Data/MySQL/Resources/004_AssetStore.sql
create mode 100644 OpenSim/Data/SQLite/Resources/002_AssetStore.sql
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
index 44d78ed..3f2e8a7 100644
--- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
@@ -63,6 +63,7 @@ namespace OpenSim.Data.MSSQL
database.ExecuteResourceSql("CreateAssetsTable.sql");
return;
}
+
}
///
@@ -114,9 +115,9 @@ namespace OpenSim.Data.MSSQL
SqlCommand cmd =
new SqlCommand(
- "INSERT INTO assets ([id], [name], [description], [assetType], [invType], [local], [temporary], [data])" +
+ "INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [data])" +
" VALUES " +
- "(@id, @name, @description, @assetType, @invType, @local, @temporary, @data)",
+ "(@id, @name, @description, @assetType, @local, @temporary, @data)",
database.getConnection());
using (cmd)
@@ -128,8 +129,6 @@ namespace OpenSim.Data.MSSQL
cmd.Parameters.AddWithValue("description", asset.Description);
SqlParameter e = cmd.Parameters.Add("assetType", SqlDbType.TinyInt);
e.Value = asset.Type;
- SqlParameter f = cmd.Parameters.Add("invType", SqlDbType.TinyInt);
- f.Value = asset.InvType;
SqlParameter g = cmd.Parameters.Add("local", SqlDbType.TinyInt);
g.Value = asset.Local;
SqlParameter h = cmd.Parameters.Add("temporary", SqlDbType.TinyInt);
@@ -159,7 +158,6 @@ namespace OpenSim.Data.MSSQL
"name = @name, " +
"description = @description," +
"assetType = @assetType," +
- "invType = @invType," +
"local = @local," +
"temporary = @temporary," +
"data = @data where " +
@@ -168,7 +166,6 @@ namespace OpenSim.Data.MSSQL
SqlParameter param2 = new SqlParameter("@name", asset.Name);
SqlParameter param3 = new SqlParameter("@description", asset.Description);
SqlParameter param4 = new SqlParameter("@assetType", asset.Type);
- SqlParameter param5 = new SqlParameter("@invType", asset.InvType);
SqlParameter param6 = new SqlParameter("@local", asset.Local);
SqlParameter param7 = new SqlParameter("@temporary", asset.Temporary);
SqlParameter param8 = new SqlParameter("@data", asset.Data);
@@ -177,7 +174,6 @@ namespace OpenSim.Data.MSSQL
command.Parameters.Add(param2);
command.Parameters.Add(param3);
command.Parameters.Add(param4);
- command.Parameters.Add(param5);
command.Parameters.Add(param6);
command.Parameters.Add(param7);
command.Parameters.Add(param8);
diff --git a/OpenSim/Data/MSSQL/MSSQLManager.cs b/OpenSim/Data/MSSQL/MSSQLManager.cs
index bea02fe..e421c5d 100644
--- a/OpenSim/Data/MSSQL/MSSQLManager.cs
+++ b/OpenSim/Data/MSSQL/MSSQLManager.cs
@@ -405,7 +405,6 @@ namespace OpenSim.Data.MSSQL
asset.Data = (byte[])reader["data"];
asset.Description = (string)reader["description"];
asset.FullID = new LLUUID((string)reader["id"]);
- asset.InvType = Convert.ToSByte(reader["invType"]);
asset.Local = Convert.ToBoolean(reader["local"]); // ((sbyte)reader["local"]) != 0 ? true : false;
asset.Name = (string)reader["name"];
asset.Type = Convert.ToSByte(reader["assetType"]);
diff --git a/OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql b/OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql
index c7cb21a..4d94699 100644
--- a/OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql
+++ b/OpenSim/Data/MSSQL/Resources/CreateAssetsTable.sql
@@ -6,7 +6,6 @@ CREATE TABLE [assets] (
[name] [varchar](64) NOT NULL,
[description] [varchar](64) NOT NULL,
[assetType] [tinyint] NOT NULL,
- [invType] [tinyint] NOT NULL,
[local] [tinyint] NOT NULL,
[temporary] [tinyint] NOT NULL,
[data] [image] NOT NULL,
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index d66a5c2..21d730d 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -164,7 +164,7 @@ namespace OpenSim.Data.MySQL
{
MySqlCommand cmd =
new MySqlCommand(
- "SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id",
+ "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id",
_dbConnection.Connection);
cmd.Parameters.AddWithValue("?id", assetID.ToString());
@@ -178,7 +178,6 @@ namespace OpenSim.Data.MySQL
asset.Data = (byte[]) dbReader["data"];
asset.Description = (string) dbReader["description"];
asset.FullID = assetID;
- asset.InvType = (sbyte) dbReader["invType"];
asset.Local = ((sbyte) dbReader["local"]) != 0 ? true : false;
asset.Name = (string) dbReader["name"];
asset.Type = (sbyte) dbReader["assetType"];
@@ -216,8 +215,8 @@ namespace OpenSim.Data.MySQL
MySqlCommand cmd =
new MySqlCommand(
- "REPLACE INTO assets(id, name, description, assetType, invType, local, temporary, data)" +
- "VALUES(?id, ?name, ?description, ?assetType, ?invType, ?local, ?temporary, ?data)",
+ "REPLACE INTO assets(id, name, description, assetType, local, temporary, data)" +
+ "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?data)",
_dbConnection.Connection);
// need to ensure we dispose
@@ -229,7 +228,6 @@ namespace OpenSim.Data.MySQL
cmd.Parameters.AddWithValue("?name", asset.Name);
cmd.Parameters.AddWithValue("?description", asset.Description);
cmd.Parameters.AddWithValue("?assetType", asset.Type);
- cmd.Parameters.AddWithValue("?invType", asset.InvType);
cmd.Parameters.AddWithValue("?local", asset.Local);
cmd.Parameters.AddWithValue("?temporary", asset.Temporary);
cmd.Parameters.AddWithValue("?data", asset.Data);
diff --git a/OpenSim/Data/MySQL/Resources/004_AssetStore.sql b/OpenSim/Data/MySQL/Resources/004_AssetStore.sql
new file mode 100644
index 0000000..9e9b9fe
--- /dev/null
+++ b/OpenSim/Data/MySQL/Resources/004_AssetStore.sql
@@ -0,0 +1,5 @@
+BEGIN;
+
+ALTER TABLE assets drop InvType;
+
+COMMIT;
diff --git a/OpenSim/Data/SQLite/Resources/002_AssetStore.sql b/OpenSim/Data/SQLite/Resources/002_AssetStore.sql
new file mode 100644
index 0000000..41ca640
--- /dev/null
+++ b/OpenSim/Data/SQLite/Resources/002_AssetStore.sql
@@ -0,0 +1,10 @@
+BEGIN TRANSACTION;
+
+CREATE TEMPORARY TABLE assets_backup(UUID,Name,Description,Type,Local,Temporary,Data);
+INSERT INTO assets_backup SELECT UUID,Name,Description,Type,Local,Temporary,Data FROM assets;
+DROP TABLE assets;
+CREATE TABLE assets(UUID,Name,Description,Type,Local,Temporary,Data);
+INSERT INTO assets SELECT UUID,Name,Description,Type,Local,Temporary,Data FROM assets_backup;
+DROP TABLE assets_backup;
+
+COMMIT;
diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs
index 24c75e3..8fa09fc 100644
--- a/OpenSim/Data/SQLite/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs
@@ -50,8 +50,8 @@ namespace OpenSim.Data.SQLite
///
private const string SelectAssetSQL = "select * from assets where UUID=:UUID";
private const string DeleteAssetSQL = "delete from assets where UUID=:UUID";
- private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, InvType, Local, Temporary, Data) values(:UUID, :Name, :Description, :Type, :InvType, :Local, :Temporary, :Data)";
- private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, InvType=:InvType, Local=:Local, Temporary=:Temporary, Data=:Data where UUID=:UUID";
+ private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Data)";
+ private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, Data=:Data where UUID=:UUID";
private const string assetSelect = "select * from assets";
private SqliteConnection m_conn;
@@ -134,7 +134,6 @@ namespace OpenSim.Data.SQLite
cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name));
cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description));
cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type));
- cmd.Parameters.Add(new SqliteParameter(":InvType", asset.InvType));
cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
@@ -158,7 +157,6 @@ namespace OpenSim.Data.SQLite
cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name));
cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description));
cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type));
- cmd.Parameters.Add(new SqliteParameter(":InvType", asset.InvType));
cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));
@@ -180,9 +178,9 @@ namespace OpenSim.Data.SQLite
int assetLength = (asset.Data != null) ? asset.Data.Length : 0;
m_log.Info("[ASSET DB]: " +
- string.Format("Loaded {6} {5} Asset: [{0}][{3}/{4}] \"{1}\":{2} ({7} bytes)",
+ string.Format("Loaded {6} {5} Asset: [{0}][{3}] \"{1}\":{2} ({7} bytes)",
asset.FullID, asset.Name, asset.Description, asset.Type,
- asset.InvType, temporary, local, assetLength));
+ temporary, local, assetLength));
}
///
@@ -258,7 +256,6 @@ namespace OpenSim.Data.SQLite
// SQLiteUtil.createCol(assets, "Name", typeof (String));
// SQLiteUtil.createCol(assets, "Description", typeof (String));
// SQLiteUtil.createCol(assets, "Type", typeof (Int32));
- // SQLiteUtil.createCol(assets, "InvType", typeof (Int32));
// SQLiteUtil.createCol(assets, "Local", typeof (Boolean));
// SQLiteUtil.createCol(assets, "Temporary", typeof (Boolean));
// SQLiteUtil.createCol(assets, "Data", typeof (Byte[]));
@@ -291,7 +288,6 @@ namespace OpenSim.Data.SQLite
asset.Name = (String) row["Name"];
asset.Description = (String) row["Description"];
asset.Type = Convert.ToSByte(row["Type"]);
- asset.InvType = Convert.ToSByte(row["InvType"]);
asset.Local = Convert.ToBoolean(row["Local"]);
asset.Temporary = Convert.ToBoolean(row["Temporary"]);
asset.Data = (byte[]) row["Data"];
--
cgit v1.1