Fix PgSQL adapter for UserProfiles
parent
a6f8f9d003
commit
1812cecdb7
|
@ -41,6 +41,8 @@ namespace OpenSim.Data.PGSQL
|
||||||
{
|
{
|
||||||
static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
protected PGSQLManager m_database;
|
||||||
|
|
||||||
#region Properites
|
#region Properites
|
||||||
string ConnectionString
|
string ConnectionString
|
||||||
{
|
{
|
||||||
|
@ -74,6 +76,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
Migration m = new Migration(dbcon, Assembly, "UserProfiles");
|
Migration m = new Migration(dbcon, Assembly, "UserProfiles");
|
||||||
m.Update();
|
m.Update();
|
||||||
|
m_database = new PGSQLManager(ConnectionString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion Member Functions
|
#endregion Member Functions
|
||||||
|
@ -94,11 +97,11 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString))
|
using (NpgsqlConnection dbcon = new NpgsqlConnection(ConnectionString))
|
||||||
{
|
{
|
||||||
string query = @"SELECT ""classifieduuid"", ""name"" FROM classifieds WHERE ""creatoruuid"" = :Id";
|
string query = @"SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = :Id";
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("Id", creatorId);
|
cmd.Parameters.Add(m_database.CreateParameter("Id", creatorId));
|
||||||
using( NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
|
using( NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
|
||||||
{
|
{
|
||||||
if(reader.HasRows)
|
if(reader.HasRows)
|
||||||
|
@ -111,7 +114,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
string Name = null;
|
string Name = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
UUID.TryParse(Convert.ToString( reader["classifieduuid"]), out Id);
|
Id = DBGuid.FromDB(reader["classifieduuid"]);
|
||||||
Name = Convert.ToString(reader["name"]);
|
Name = Convert.ToString(reader["name"]);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -132,27 +135,24 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result)
|
public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result)
|
||||||
{
|
{
|
||||||
string query = @"INSERT INTO classifieds ( ""classifieduuid"",""creatoruuid"", ""creationdate"", ""expirationdate"", ""category"",
|
string query = string.Empty;
|
||||||
""name"", ""description"", ""parceluuid"", ""parentestate"", ""snapshotuuid"", ""simname"",
|
|
||||||
""posglobal"", ""parcelname"", ""classifiedflags"", ""priceforlisting"")
|
|
||||||
Select :ClassifiedId, :CreatorId, :CreatedDate, :ExpirationDate, :Category,
|
|
||||||
:Name, :Description, :ParcelId, :ParentEstate, :SnapshotId, :SimName
|
|
||||||
:GlobalPos, :ParcelName, :Flags, :ListingPrice
|
|
||||||
Where not exists( Select ""classifieduuid"" from classifieds where ""classifieduuid"" = :ClassifiedId );
|
|
||||||
|
|
||||||
update classifieds
|
query = @"WITH upsert AS (
|
||||||
set category =:Category,
|
UPDATE classifieds SET
|
||||||
expirationdate = :ExpirationDate,
|
classifieduuid = :ClassifiedId, creatoruuid = :CreatorId, creationdate = :CreatedDate,
|
||||||
name = :Name,
|
expirationdate = :ExpirationDate,category =:Category, name = :Name, description = :Description,
|
||||||
description = :Description,
|
parceluuid = :ParcelId, parentestate = :ParentEstate, snapshotuuid = :SnapshotId,
|
||||||
parentestate = :ParentEstate,
|
simname = :SimName, posglobal = :GlobalPos, parcelname = :ParcelName, classifiedflags = :Flags,
|
||||||
posglobal = :GlobalPos,
|
priceforlisting = :ListingPrice
|
||||||
parcelname = :ParcelName,
|
RETURNING * )
|
||||||
classifiedflags = :Flags,
|
INSERT INTO classifieds (classifieduuid,creatoruuid,creationdate,expirationdate,category,name,
|
||||||
priceforlisting = :ListingPrice,
|
description,parceluuid,parentestate,snapshotuuid,simname,posglobal,parcelname,classifiedflags,
|
||||||
snapshotuuid = :SnapshotId
|
priceforlisting)
|
||||||
where classifieduuid = :ClassifiedId ;
|
SELECT
|
||||||
";
|
:ClassifiedId,:CreatorId,:CreatedDate,:ExpirationDate,:Category,:Name,:Description,
|
||||||
|
:ParcelId,:ParentEstate,:SnapshotId,:SimName,:GlobalPos,:ParcelName,:Flags,:ListingPrice
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT * FROM upsert )";
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(ad.ParcelName))
|
if(string.IsNullOrEmpty(ad.ParcelName))
|
||||||
ad.ParcelName = "Unknown";
|
ad.ParcelName = "Unknown";
|
||||||
|
@ -190,21 +190,21 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("ClassifiedId", ad.ClassifiedId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("ClassifiedId", ad.ClassifiedId));
|
||||||
cmd.Parameters.AddWithValue("CreatorId", ad.CreatorId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("CreatorId", ad.CreatorId));
|
||||||
cmd.Parameters.AddWithValue("CreatedDate", ad.CreationDate.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("CreatedDate", (int)ad.CreationDate));
|
||||||
cmd.Parameters.AddWithValue("ExpirationDate", ad.ExpirationDate.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("ExpirationDate", (int)ad.ExpirationDate));
|
||||||
cmd.Parameters.AddWithValue("Category", ad.Category.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Category", ad.Category.ToString()));
|
||||||
cmd.Parameters.AddWithValue("Name", ad.Name.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Name", ad.Name.ToString()));
|
||||||
cmd.Parameters.AddWithValue("Description", ad.Description.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Description", ad.Description.ToString()));
|
||||||
cmd.Parameters.AddWithValue("ParcelId", ad.ParcelId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("ParcelId", ad.ParcelId));
|
||||||
cmd.Parameters.AddWithValue("ParentEstate", ad.ParentEstate.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("ParentEstate", (int)ad.ParentEstate));
|
||||||
cmd.Parameters.AddWithValue("SnapshotId", ad.SnapshotId.ToString ());
|
cmd.Parameters.Add(m_database.CreateParameter("SnapshotId", ad.SnapshotId));
|
||||||
cmd.Parameters.AddWithValue("SimName", ad.SimName.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("SimName", ad.SimName.ToString()));
|
||||||
cmd.Parameters.AddWithValue("GlobalPos", ad.GlobalPos.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("GlobalPos", ad.GlobalPos.ToString()));
|
||||||
cmd.Parameters.AddWithValue("ParcelName", ad.ParcelName.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("ParcelName", ad.ParcelName.ToString()));
|
||||||
cmd.Parameters.AddWithValue("Flags", ad.Flags.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Flags", (int)Convert.ToInt32(ad.Flags)));
|
||||||
cmd.Parameters.AddWithValue("ListingPrice", ad.Price.ToString ());
|
cmd.Parameters.Add(m_database.CreateParameter("ListingPrice", (int)Convert.ToInt32(ad.Price)));
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("ClassifiedId", recordId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("ClassifiedId", recordId));
|
||||||
|
|
||||||
lock(Lock)
|
lock(Lock)
|
||||||
{
|
{
|
||||||
|
@ -267,15 +267,18 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("AdId", ad.ClassifiedId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("AdId", ad.ClassifiedId));
|
||||||
|
|
||||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
if(reader.Read ())
|
if(reader.Read ())
|
||||||
{
|
{
|
||||||
ad.CreatorId = GetUUID(reader["creatoruuid"]);
|
// ad.CreatorId = GetUUID(reader["creatoruuid"]);
|
||||||
ad.ParcelId = GetUUID(reader["parceluuid"]);
|
ad.CreatorId = DBGuid.FromDB(reader["creatoruuid"]);
|
||||||
ad.SnapshotId = GetUUID(reader["snapshotuuid"]);
|
// ad.ParcelId = GetUUID(reader["parceluuid"]);
|
||||||
|
ad.ParcelId = DBGuid.FromDB(reader["parceluuid"]);
|
||||||
|
// ad.SnapshotId = GetUUID(reader["snapshotuuid"]);
|
||||||
|
ad.SnapshotId = DBGuid.FromDB(reader["snapshotuuid"]);
|
||||||
ad.CreationDate = Convert.ToInt32(reader["creationdate"]);
|
ad.CreationDate = Convert.ToInt32(reader["creationdate"]);
|
||||||
ad.ExpirationDate = Convert.ToInt32(reader["expirationdate"]);
|
ad.ExpirationDate = Convert.ToInt32(reader["expirationdate"]);
|
||||||
ad.ParentEstate = Convert.ToInt32(reader["parentestate"]);
|
ad.ParentEstate = Convert.ToInt32(reader["parentestate"]);
|
||||||
|
@ -297,7 +300,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[PROFILES_DATA]" +
|
m_log.DebugFormat("[PROFILES_DATA]" +
|
||||||
": GetPickInfo exception {0}", e.Message);
|
": GetClassifiedInfo exception {0}", e.Message);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -330,7 +333,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("Id", avatarId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId));
|
||||||
|
|
||||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
|
@ -340,7 +343,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
{
|
{
|
||||||
OSDMap record = new OSDMap();
|
OSDMap record = new OSDMap();
|
||||||
|
|
||||||
record.Add("pickuuid",OSD.FromString((string)reader["pickuuid"]));
|
record.Add("pickuuid",OSD.FromUUID(DBGuid.FromDB(reader["pickuuid"])));
|
||||||
record.Add("name",OSD.FromString((string)reader["name"]));
|
record.Add("name",OSD.FromString((string)reader["name"]));
|
||||||
data.Add(record);
|
data.Add(record);
|
||||||
}
|
}
|
||||||
|
@ -373,8 +376,8 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("CreatorId", avatarId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("CreatorId", avatarId));
|
||||||
cmd.Parameters.AddWithValue("PickId", pickId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("PickId", pickId));
|
||||||
|
|
||||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
|
@ -387,18 +390,18 @@ namespace OpenSim.Data.PGSQL
|
||||||
if (string.IsNullOrEmpty(description))
|
if (string.IsNullOrEmpty(description))
|
||||||
description = "No description given.";
|
description = "No description given.";
|
||||||
|
|
||||||
UUID.TryParse((string)reader["pickuuid"], out pick.PickId);
|
pick.PickId = DBGuid.FromDB(reader["pickuuid"]);
|
||||||
UUID.TryParse((string)reader["creatoruuid"], out pick.CreatorId);
|
pick.CreatorId = DBGuid.FromDB(reader["creatoruuid"]);
|
||||||
UUID.TryParse((string)reader["parceluuid"], out pick.ParcelId);
|
pick.ParcelId = DBGuid.FromDB(reader["parceluuid"]);
|
||||||
UUID.TryParse((string)reader["snapshotuuid"], out pick.SnapshotId);
|
pick.SnapshotId = DBGuid.FromDB(reader["snapshotuuid"]);
|
||||||
pick.GlobalPos = (string)reader["posglobal"];
|
pick.GlobalPos = (string)reader["posglobal"].ToString();
|
||||||
bool.TryParse((string)reader["toppick"], out pick.TopPick);
|
pick.TopPick = Convert.ToBoolean(reader["toppick"]);
|
||||||
bool.TryParse((string)reader["enabled"], out pick.Enabled);
|
pick.Enabled = Convert.ToBoolean(reader["enabled"]);
|
||||||
pick.Name = (string)reader["name"];
|
pick.Name = reader["name"].ToString ();
|
||||||
pick.Desc = description;
|
pick.Desc = reader["description"].ToString();
|
||||||
pick.User = (string)reader["user"];
|
pick.User = reader["user"].ToString();
|
||||||
pick.OriginalName = (string)reader["originalname"];
|
pick.OriginalName = reader["originalname"].ToString();
|
||||||
pick.SimName = (string)reader["simname"];
|
pick.SimName = reader["simname"].ToString();
|
||||||
pick.SortOrder = (int)reader["sortorder"];
|
pick.SortOrder = (int)reader["sortorder"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -418,19 +421,22 @@ namespace OpenSim.Data.PGSQL
|
||||||
{
|
{
|
||||||
string query = string.Empty;
|
string query = string.Empty;
|
||||||
|
|
||||||
query = @"INSERT INTO userpicks VALUES ( :PickId, :CreatorId, :TopPick, :ParcelId,:Name, :Desc, :SnapshotId,:User,
|
|
||||||
:Original, :SimName, :GlobalPos, :SortOrder, :Enabled)
|
|
||||||
where not exists ( select pickid from userpicks where pickid = :pickid);
|
|
||||||
|
|
||||||
Update userpicks
|
query = @"WITH upsert AS (
|
||||||
set parceluuid = :ParcelId,
|
UPDATE userpicks SET
|
||||||
name = :Name,
|
pickuuid = :PickId, creatoruuid = :CreatorId, toppick = :TopPick, parceluuid = :ParcelId,
|
||||||
description = :Desc,
|
name = :Name, description = :Desc, snapshotuuid = :SnapshotId, ""user"" = :User,
|
||||||
snapshotuuid = :SnapshotId,
|
originalname = :Original, simname = :SimName, posglobal = :GlobalPos,
|
||||||
pickuuid = :PickId,
|
sortorder = :SortOrder, enabled = :Enabled
|
||||||
posglobal = :GlobalPos
|
RETURNING * )
|
||||||
where pickid = :PickId;
|
INSERT INTO userpicks (pickuuid,creatoruuid,toppick,parceluuid,name,description,
|
||||||
";
|
snapshotuuid,""user"",originalname,simname,posglobal,sortorder,enabled)
|
||||||
|
SELECT
|
||||||
|
:PickId,:CreatorId,:TopPick,:ParcelId,:Name,:Desc,:SnapshotId,:User,
|
||||||
|
:Original,:SimName,:GlobalPos,:SortOrder,:Enabled
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT * FROM upsert )";
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -439,19 +445,19 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("PickId", pick.PickId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("PickId", pick.PickId));
|
||||||
cmd.Parameters.AddWithValue("CreatorId", pick.CreatorId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("CreatorId", pick.CreatorId));
|
||||||
cmd.Parameters.AddWithValue("TopPick", pick.TopPick.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("TopPick", pick.TopPick));
|
||||||
cmd.Parameters.AddWithValue("ParcelId", pick.ParcelId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("ParcelId", pick.ParcelId));
|
||||||
cmd.Parameters.AddWithValue("Name", pick.Name.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Name", pick.Name));
|
||||||
cmd.Parameters.AddWithValue("Desc", pick.Desc.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Desc", pick.Desc));
|
||||||
cmd.Parameters.AddWithValue("SnapshotId", pick.SnapshotId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("SnapshotId", pick.SnapshotId));
|
||||||
cmd.Parameters.AddWithValue("User", pick.User.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("User", pick.User));
|
||||||
cmd.Parameters.AddWithValue("Original", pick.OriginalName.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Original", pick.OriginalName));
|
||||||
cmd.Parameters.AddWithValue("SimName",pick.SimName.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("SimName",pick.SimName));
|
||||||
cmd.Parameters.AddWithValue("GlobalPos", pick.GlobalPos);
|
cmd.Parameters.Add(m_database.CreateParameter("GlobalPos", pick.GlobalPos));
|
||||||
cmd.Parameters.AddWithValue("SortOrder", pick.SortOrder.ToString ());
|
cmd.Parameters.Add(m_database.CreateParameter("SortOrder", pick.SortOrder));
|
||||||
cmd.Parameters.AddWithValue("Enabled", pick.Enabled.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Enabled", pick.Enabled));
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
@ -481,7 +487,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("PickId", pickId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("PickId", pickId));
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
@ -514,8 +520,8 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("Id", notes.UserId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Id", notes.UserId));
|
||||||
cmd.Parameters.AddWithValue("TargetId", notes.TargetId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("TargetId", notes.TargetId));
|
||||||
|
|
||||||
using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
{
|
{
|
||||||
|
@ -551,14 +557,25 @@ namespace OpenSim.Data.PGSQL
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
remove = false;
|
remove = false;
|
||||||
query = @"INSERT INTO usernotes VALUES ( :UserId, :TargetId, :Notes )
|
// query = @"INSERT INTO usernotes VALUES ( :UserId, :TargetId, :Notes )
|
||||||
where not exists ( Select useruuid from usernotes where useruuid = :UserId and targetuuid = :TargetId );
|
// where not exists ( Select useruuid from usernotes where useruuid = :UserId and targetuuid = :TargetId );
|
||||||
|
//
|
||||||
|
// update usernotes
|
||||||
|
// set notes = :Notes
|
||||||
|
// where useruuid = :UserId
|
||||||
|
// and targetuuid = :TargetId;
|
||||||
|
// ";
|
||||||
|
|
||||||
|
|
||||||
|
query = @"WITH upsert AS (
|
||||||
|
UPDATE usernotes SET notes = :Notes, useruuid = :UserId, targetuuid = :TargetId RETURNING * )
|
||||||
|
INSERT INTO usernotes (notes,useruuid,targetuuid)
|
||||||
|
SELECT :Notes,:UserId,:TargetId
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT * FROM upsert
|
||||||
|
)";
|
||||||
|
|
||||||
|
|
||||||
update usernotes
|
|
||||||
set notes = :Notes
|
|
||||||
where useruuid = :UserId
|
|
||||||
and targetuuid = :TargetId;
|
|
||||||
";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -569,9 +586,9 @@ namespace OpenSim.Data.PGSQL
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
if(!remove)
|
if(!remove)
|
||||||
cmd.Parameters.AddWithValue("Notes", note.Notes);
|
cmd.Parameters.Add(m_database.CreateParameter("Notes", note.Notes));
|
||||||
cmd.Parameters.AddWithValue("TargetId", note.TargetId.ToString ());
|
cmd.Parameters.Add(m_database.CreateParameter("TargetId", note.TargetId));
|
||||||
cmd.Parameters.AddWithValue("UserId", note.UserId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("UserId", note.UserId));
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
@ -603,7 +620,8 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("Id", props.UserId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Id", props.UserId));
|
||||||
|
m_log.InfoFormat("Profile Data {0}", props.ToString());
|
||||||
|
|
||||||
using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
{
|
{
|
||||||
|
@ -612,12 +630,15 @@ namespace OpenSim.Data.PGSQL
|
||||||
m_log.DebugFormat("[PROFILES_DATA]" +
|
m_log.DebugFormat("[PROFILES_DATA]" +
|
||||||
": Getting data for {0}.", props.UserId);
|
": Getting data for {0}.", props.UserId);
|
||||||
reader.Read();
|
reader.Read();
|
||||||
props.WebUrl = (string)reader["profileURL"];
|
props.WebUrl = (string)reader["profileURL"].ToString();
|
||||||
UUID.TryParse((string)reader["profileImage"], out props.ImageId);
|
m_log.DebugFormat("[PROFILES_DATA]: WebURL {0} ", props.WebUrl);
|
||||||
|
// UUID.TryParse((string)reader["profileImage"], out props.ImageId);
|
||||||
|
props.ImageId = DBGuid.FromDB(reader["profileImage"]);
|
||||||
|
m_log.DebugFormat("[PROFILES_DATA]: profileImage {0} ", props.ImageId);
|
||||||
props.AboutText = (string)reader["profileAboutText"];
|
props.AboutText = (string)reader["profileAboutText"];
|
||||||
UUID.TryParse((string)reader["profileFirstImage"], out props.FirstLifeImageId);
|
props.FirstLifeImageId = DBGuid.FromDB(reader["profileFirstImage"]);
|
||||||
props.FirstLifeText = (string)reader["profileFirstText"];
|
props.FirstLifeText = (string)reader["profileFirstText"];
|
||||||
UUID.TryParse((string)reader["profilePartner"], out props.PartnerId);
|
props.PartnerId = DBGuid.FromDB(reader["profilePartner"]);
|
||||||
props.WantToMask = (int)reader["profileWantToMask"];
|
props.WantToMask = (int)reader["profileWantToMask"];
|
||||||
props.WantToText = (string)reader["profileWantToText"];
|
props.WantToText = (string)reader["profileWantToText"];
|
||||||
props.SkillsMask = (int)reader["profileSkillsMask"];
|
props.SkillsMask = (int)reader["profileSkillsMask"];
|
||||||
|
@ -645,19 +666,19 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
query = "INSERT INTO userprofile (";
|
query = "INSERT INTO userprofile (";
|
||||||
query += "useruuid, ";
|
query += "useruuid, ";
|
||||||
query += "profilePartner, ";
|
query += "\"profilePartner\", ";
|
||||||
query += "profileAllowPublish, ";
|
query += "\"profileAllowPublish\", ";
|
||||||
query += "profileMaturePublish, ";
|
query += "\"profileMaturePublish\", ";
|
||||||
query += "profileURL, ";
|
query += "\"profileURL\", ";
|
||||||
query += "profileWantToMask, ";
|
query += "\"profileWantToMask\", ";
|
||||||
query += "profileWantToText, ";
|
query += "\"profileWantToText\", ";
|
||||||
query += "profileSkillsMask, ";
|
query += "\"profileSkillsMask\", ";
|
||||||
query += "profileSkillsText, ";
|
query += "\"profileSkillsText\", ";
|
||||||
query += "profileLanguages, ";
|
query += "\"profileLanguages\", ";
|
||||||
query += "profileImage, ";
|
query += "\"profileImage\", ";
|
||||||
query += "profileAboutText, ";
|
query += "\"profileAboutText\", ";
|
||||||
query += "profileFirstImage, ";
|
query += "\"profileFirstImage\", ";
|
||||||
query += "profileFirstText) VALUES (";
|
query += "\"profileFirstText\") VALUES (";
|
||||||
query += ":userId, ";
|
query += ":userId, ";
|
||||||
query += ":profilePartner, ";
|
query += ":profilePartner, ";
|
||||||
query += ":profileAllowPublish, ";
|
query += ":profileAllowPublish, ";
|
||||||
|
@ -678,20 +699,23 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
using (NpgsqlCommand put = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand put = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
put.Parameters.AddWithValue("userId", props.UserId.ToString());
|
m_log.DebugFormat("[PROFILES_DATA]" +
|
||||||
put.Parameters.AddWithValue("profilePartner", props.PartnerId.ToString());
|
": Adding new data for {0}", props.UserId);
|
||||||
put.Parameters.AddWithValue("profileAllowPublish", props.PublishProfile);
|
|
||||||
put.Parameters.AddWithValue("profileMaturePublish", props.PublishMature);
|
put.Parameters.Add(m_database.CreateParameter("userId", props.UserId));
|
||||||
put.Parameters.AddWithValue("profileURL", props.WebUrl);
|
put.Parameters.Add(m_database.CreateParameter("profilePartner", props.PartnerId));
|
||||||
put.Parameters.AddWithValue("profileWantToMask", props.WantToMask);
|
put.Parameters.Add(m_database.CreateParameter("profileAllowPublish", props.PublishProfile));
|
||||||
put.Parameters.AddWithValue("profileWantToText", props.WantToText);
|
put.Parameters.Add(m_database.CreateParameter("profileMaturePublish", props.PublishMature));
|
||||||
put.Parameters.AddWithValue("profileSkillsMask", props.SkillsMask);
|
put.Parameters.Add(m_database.CreateParameter("profileURL", props.WebUrl));
|
||||||
put.Parameters.AddWithValue("profileSkillsText", props.SkillsText);
|
put.Parameters.Add(m_database.CreateParameter("profileWantToMask", props.WantToMask));
|
||||||
put.Parameters.AddWithValue("profileLanguages", props.Language);
|
put.Parameters.Add(m_database.CreateParameter("profileWantToText", props.WantToText));
|
||||||
put.Parameters.AddWithValue("profileImage", props.ImageId.ToString());
|
put.Parameters.Add(m_database.CreateParameter("profileSkillsMask", props.SkillsMask));
|
||||||
put.Parameters.AddWithValue("profileAboutText", props.AboutText);
|
put.Parameters.Add(m_database.CreateParameter("profileSkillsText", props.SkillsText));
|
||||||
put.Parameters.AddWithValue("profileFirstImage", props.FirstLifeImageId.ToString());
|
put.Parameters.Add(m_database.CreateParameter("profileLanguages", props.Language));
|
||||||
put.Parameters.AddWithValue("profileFirstText", props.FirstLifeText);
|
put.Parameters.Add(m_database.CreateParameter("profileImage", props.ImageId));
|
||||||
|
put.Parameters.Add(m_database.CreateParameter("profileAboutText", props.AboutText));
|
||||||
|
put.Parameters.Add(m_database.CreateParameter("profileFirstImage", props.FirstLifeImageId));
|
||||||
|
put.Parameters.Add(m_database.CreateParameter("profileFirstText", props.FirstLifeText));
|
||||||
|
|
||||||
put.ExecuteNonQuery();
|
put.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
@ -703,7 +727,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[PROFILES_DATA]" +
|
m_log.DebugFormat("[PROFILES_DATA]" +
|
||||||
": Requst properties exception {0}", e.Message);
|
": Requst properties exception {0} {1}", e.Message, e.StackTrace);
|
||||||
result = e.Message;
|
result = e.Message;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -715,12 +739,12 @@ namespace OpenSim.Data.PGSQL
|
||||||
string query = string.Empty;
|
string query = string.Empty;
|
||||||
|
|
||||||
query += "UPDATE userprofile SET ";
|
query += "UPDATE userprofile SET ";
|
||||||
query += "profileURL=:profileURL, ";
|
query += "\"profileURL\"=:profileURL, ";
|
||||||
query += "profileImage=:image, ";
|
query += "\"profileImage\"=:image, ";
|
||||||
query += "profileAboutText=:abouttext,";
|
query += "\"profileAboutText\"=:abouttext,";
|
||||||
query += "profileFirstImage=:firstlifeimage,";
|
query += "\"profileFirstImage\"=:firstlifeimage,";
|
||||||
query += "profileFirstText=:firstlifetext ";
|
query += "\"profileFirstText\"=:firstlifetext ";
|
||||||
query += "WHERE useruuid=:uuid";
|
query += "WHERE \"useruuid\"=:uuid";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -729,12 +753,12 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("profileURL", props.WebUrl);
|
cmd.Parameters.Add(m_database.CreateParameter("profileURL", props.WebUrl));
|
||||||
cmd.Parameters.AddWithValue("image", props.ImageId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("image", props.ImageId));
|
||||||
cmd.Parameters.AddWithValue("abouttext", props.AboutText);
|
cmd.Parameters.Add(m_database.CreateParameter("abouttext", props.AboutText));
|
||||||
cmd.Parameters.AddWithValue("firstlifeimage", props.FirstLifeImageId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("firstlifeimage", props.FirstLifeImageId));
|
||||||
cmd.Parameters.AddWithValue("firstlifetext", props.FirstLifeText);
|
cmd.Parameters.Add(m_database.CreateParameter("firstlifetext", props.FirstLifeText));
|
||||||
cmd.Parameters.AddWithValue("uuid", props.UserId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("uuid", props.UserId));
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
@ -757,12 +781,12 @@ namespace OpenSim.Data.PGSQL
|
||||||
string query = string.Empty;
|
string query = string.Empty;
|
||||||
|
|
||||||
query += "UPDATE userprofile SET ";
|
query += "UPDATE userprofile SET ";
|
||||||
query += "profileWantToMask=:WantMask, ";
|
query += "\"profileWantToMask\"=:WantMask, ";
|
||||||
query += "profileWantToText=:WantText,";
|
query += "\"profileWantToText\"=:WantText,";
|
||||||
query += "profileSkillsMask=:SkillsMask,";
|
query += "\"profileSkillsMask\"=:SkillsMask,";
|
||||||
query += "profileSkillsText=:SkillsText, ";
|
query += "\"profileSkillsText\"=:SkillsText, ";
|
||||||
query += "profileLanguages=:Languages ";
|
query += "\"profileLanguages\"=:Languages ";
|
||||||
query += "WHERE useruuid=:uuid";
|
query += "WHERE \"useruuid\"=:uuid";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -771,12 +795,12 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("WantMask", up.WantToMask);
|
cmd.Parameters.Add(m_database.CreateParameter("WantMask", up.WantToMask));
|
||||||
cmd.Parameters.AddWithValue("WantText", up.WantToText);
|
cmd.Parameters.Add(m_database.CreateParameter("WantText", up.WantToText));
|
||||||
cmd.Parameters.AddWithValue("SkillsMask", up.SkillsMask);
|
cmd.Parameters.Add(m_database.CreateParameter("SkillsMask", up.SkillsMask));
|
||||||
cmd.Parameters.AddWithValue("SkillsText", up.SkillsText);
|
cmd.Parameters.Add(m_database.CreateParameter("SkillsText", up.SkillsText));
|
||||||
cmd.Parameters.AddWithValue("Languages", up.Language);
|
cmd.Parameters.Add(m_database.CreateParameter("Languages", up.Language));
|
||||||
cmd.Parameters.AddWithValue("uuid", up.UserId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("uuid", up.UserId));
|
||||||
|
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
@ -809,7 +833,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format (query,"\"classifieds\""), dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format (query,"\"classifieds\""), dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("Id", avatarId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId));
|
||||||
|
|
||||||
using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
{
|
{
|
||||||
|
@ -817,7 +841,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
{
|
{
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
data.Add(new OSDString((string)reader["snapshotuuid"].ToString ()));
|
data.Add(new OSDString((string)reader["snapshotuuid"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -828,7 +852,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format (query,"\"userpicks\""), dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format (query,"\"userpicks\""), dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("Id", avatarId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId));
|
||||||
|
|
||||||
using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
{
|
{
|
||||||
|
@ -836,7 +860,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
{
|
{
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
data.Add(new OSDString((string)reader["snapshotuuid"].ToString ()));
|
data.Add(new OSDString((string)reader["snapshotuuid"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -849,7 +873,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format (query,"\"userpicks\""), dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(string.Format (query,"\"userpicks\""), dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("Id", avatarId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Id", avatarId));
|
||||||
|
|
||||||
using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
{
|
{
|
||||||
|
@ -857,8 +881,8 @@ namespace OpenSim.Data.PGSQL
|
||||||
{
|
{
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
data.Add(new OSDString((string)reader["profileImage"].ToString ()));
|
data.Add(new OSDString((string)reader["profileImage"]));
|
||||||
data.Add(new OSDString((string)reader["profileFirstImage"].ToString ()));
|
data.Add(new OSDString((string)reader["profileFirstImage"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -891,7 +915,7 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("Id", pref.UserId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Id", pref.UserId));
|
||||||
|
|
||||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
|
@ -944,9 +968,9 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("ImViaEmail", pref.IMViaEmail.ToString().ToLower ());
|
cmd.Parameters.Add(m_database.CreateParameter("ImViaEmail", pref.IMViaEmail.ToString().ToLower ()));
|
||||||
cmd.Parameters.AddWithValue("Visible", pref.Visible.ToString().ToLower ());
|
cmd.Parameters.Add(m_database.CreateParameter("Visible", pref.Visible.ToString().ToLower ()));
|
||||||
cmd.Parameters.AddWithValue("uuid", pref.UserId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("uuid", pref.UserId.ToString()));
|
||||||
|
|
||||||
lock(Lock)
|
lock(Lock)
|
||||||
{
|
{
|
||||||
|
@ -982,8 +1006,8 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("Id", props.UserId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("Id", props.UserId));
|
||||||
cmd.Parameters.AddWithValue (":TagId", props.TagId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter(":TagId", props.TagId));
|
||||||
|
|
||||||
using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
using (NpgsqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||||
{
|
{
|
||||||
|
@ -1003,10 +1027,10 @@ namespace OpenSim.Data.PGSQL
|
||||||
|
|
||||||
using (NpgsqlCommand put = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand put = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
put.Parameters.AddWithValue("Id", props.UserId.ToString());
|
put.Parameters.Add(m_database.CreateParameter("Id", props.UserId));
|
||||||
put.Parameters.AddWithValue("TagId", props.TagId.ToString());
|
put.Parameters.Add(m_database.CreateParameter("TagId", props.TagId));
|
||||||
put.Parameters.AddWithValue("DataKey", props.DataKey.ToString());
|
put.Parameters.Add(m_database.CreateParameter("DataKey", props.DataKey.ToString()));
|
||||||
put.Parameters.AddWithValue("DataVal", props.DataVal.ToString());
|
put.Parameters.Add(m_database.CreateParameter("DataVal", props.DataVal.ToString()));
|
||||||
|
|
||||||
lock(Lock)
|
lock(Lock)
|
||||||
{
|
{
|
||||||
|
@ -1046,10 +1070,10 @@ namespace OpenSim.Data.PGSQL
|
||||||
dbcon.Open();
|
dbcon.Open();
|
||||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
using (NpgsqlCommand cmd = new NpgsqlCommand(query, dbcon))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("UserId", props.UserId.ToString());
|
cmd.Parameters.Add(m_database.CreateParameter("UserId", props.UserId.ToString()));
|
||||||
cmd.Parameters.AddWithValue("TagId", props.TagId.ToString ());
|
cmd.Parameters.Add(m_database.CreateParameter("TagId", props.TagId.ToString ()));
|
||||||
cmd.Parameters.AddWithValue("DataKey", props.DataKey.ToString ());
|
cmd.Parameters.Add(m_database.CreateParameter("DataKey", props.DataKey.ToString ()));
|
||||||
cmd.Parameters.AddWithValue("DataVal", props.DataKey.ToString ());
|
cmd.Parameters.Add(m_database.CreateParameter("DataVal", props.DataKey.ToString ()));
|
||||||
|
|
||||||
lock(Lock)
|
lock(Lock)
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,3 +90,57 @@ CREATE TABLE usersettings (
|
||||||
PRIMARY KEY ("useruuid")
|
PRIMARY KEY ("useruuid")
|
||||||
);
|
);
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
|
:VERSION 4
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
-- Classifieds
|
||||||
|
ALTER TABLE classifieds DROP CONSTRAINT classifiedspk;
|
||||||
|
ALTER TABLE classifieds ALTER COLUMN classifieduuid SET DATA TYPE uuid using classifieduuid::uuid;
|
||||||
|
ALTER TABLE classifieds ALTER COLUMN creatoruuid SET DATA TYPE uuid using creatoruuid::uuid;
|
||||||
|
ALTER TABLE classifieds ALTER COLUMN parceluuid SET DATA TYPE uuid using parceluuid::uuid;
|
||||||
|
ALTER TABLE classifieds ALTER COLUMN snapshotuuid SET DATA TYPE uuid using snapshotuuid::uuid;
|
||||||
|
ALTER TABLE classifieds ADD CONSTRAINT classifiedspk PRIMARY KEY (classifieduuid);
|
||||||
|
|
||||||
|
-- Notes
|
||||||
|
ALTER TABLE usernotes DROP CONSTRAINT usernoteuk;
|
||||||
|
ALTER TABLE usernotes ALTER COLUMN useruuid SET DATA TYPE uuid USING useruuid::uuid;
|
||||||
|
ALTER TABLE usernotes ALTER COLUMN targetuuid SET DATA TYPE uuid USING targetuuid::uuid;
|
||||||
|
ALTER TABLE usernotes ADD CONSTRAINT usernoteuk UNIQUE (useruuid,targetuuid);
|
||||||
|
|
||||||
|
|
||||||
|
-- Userpicks
|
||||||
|
ALTER TABLE userpicks DROP CONSTRAINT userpicks_pkey;
|
||||||
|
ALTER TABLE userpicks ALTER COLUMN pickuuid SET DATA TYPE uuid USING pickuuid::uuid;
|
||||||
|
ALTER TABLE userpicks ALTER COLUMN creatoruuid SET DATA TYPE uuid USING creatoruuid::uuid;
|
||||||
|
ALTER TABLE userpicks ALTER COLUMN parceluuid SET DATA TYPE uuid USING parceluuid::uuid;
|
||||||
|
ALTER TABLE userpicks ALTER COLUMN parceluuid SET DATA TYPE uuid USING parceluuid::uuid;
|
||||||
|
ALTER TABLE userpicks ADD PRIMARY KEY (pickuuid);
|
||||||
|
|
||||||
|
-- Userprofile
|
||||||
|
ALTER TABLE userprofile DROP CONSTRAINT userprofile_pkey;
|
||||||
|
ALTER TABLE userprofile ALTER COLUMN useruuid SET DATA TYPE uuid USING useruuid::uuid;
|
||||||
|
ALTER TABLE userprofile ALTER COLUMN "profilePartner" SET DATA TYPE uuid USING "profilePartner"::uuid;
|
||||||
|
-- Force column conversions
|
||||||
|
ALTER TABLE userprofile ALTER COLUMN "profileAllowPublish" SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END;
|
||||||
|
ALTER TABLE userprofile ALTER COLUMN "profileMaturePublish" SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END;
|
||||||
|
ALTER TABLE userprofile ALTER COLUMN "profileImage" SET DATA TYPE uuid USING "profileImage"::uuid;
|
||||||
|
ALTER TABLE userprofile ALTER COLUMN "profileFirstImage" SET DATA TYPE uuid USING "profileFirstImage"::uuid;
|
||||||
|
ALTER TABLE userprofile ADD PRIMARY KEY (useruuid);
|
||||||
|
|
||||||
|
-- Userdata
|
||||||
|
ALTER TABLE userdata DROP CONSTRAINT userdata_pkey;
|
||||||
|
ALTER TABLE userdata ALTER COLUMN "UserId" SET DATA TYPE uuid USING "UserId"::uuid;
|
||||||
|
ALTER TABLE userdata ALTER COLUMN "UserId" SET DATA TYPE uuid USING "UserId"::uuid;
|
||||||
|
ALTER TABLE userdata ADD PRIMARY KEY ("UserId","TagId");
|
||||||
|
|
||||||
|
|
||||||
|
-- Usersettings
|
||||||
|
ALTER TABLE usersettings DROP CONSTRAINT usersettings_pkey;
|
||||||
|
ALTER TABLE usersettings ALTER COLUMN useruuid SET DATA TYPE uuid USING useruuid::uuid;
|
||||||
|
ALTER TABLE usersettings ALTER COLUMN visible SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END;
|
||||||
|
ALTER TABLE usersettings ADD COLUMN email varchar(254) NOT NULL;
|
||||||
|
ALTER TABLE usersettings ADD PRIMARY KEY (useruuid);
|
||||||
|
|
||||||
|
COMMIT;
|
Loading…
Reference in New Issue