mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 03:06:05 +08:00
* 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
This commit is contained in:
@@ -63,6 +63,7 @@ namespace OpenSim.Data.MSSQL
|
||||
database.ExecuteResourceSql("CreateAssetsTable.sql");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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);
|
||||
|
||||
@@ -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"]);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
5
OpenSim/Data/MySQL/Resources/004_AssetStore.sql
Normal file
5
OpenSim/Data/MySQL/Resources/004_AssetStore.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE assets drop InvType;
|
||||
|
||||
COMMIT;
|
||||
10
OpenSim/Data/SQLite/Resources/002_AssetStore.sql
Normal file
10
OpenSim/Data/SQLite/Resources/002_AssetStore.sql
Normal file
@@ -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;
|
||||
@@ -50,8 +50,8 @@ namespace OpenSim.Data.SQLite
|
||||
/// </summary>
|
||||
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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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"];
|
||||
|
||||
Reference in New Issue
Block a user