here are source schema:
namespace TestPerformSafely.Model.NS1
{
[Serializable]
[HierarchyRoot]
public class MyEntity : Entity
{
[Field, Key]
public int Id { get; private set; }
[Field(Length = 100)]
public string Text { get; set; }
}
}
and destination:
namespace TestPerformSafely.Model.NS2
{
[Serializable]
[HierarchyRoot]
public class AnotherEntity : Entity
{
[Field, Key]
public int Id { get; private set; }
}
}
how could I upgrade schema from one to another at perform safely mode?
I have added hint to rename Type, but cannot add valid remove field hint:
public class Upgrader : UpgradeHandler
{
protected override void AddUpgradeHints(Xtensive.Collections.ISet<UpgradeHint> hints)
{
base.AddUpgradeHints(hints);
hints.Add(new RenameTypeHint("TestPerformSafely.Model.NS1.MyEntity", typeof(AnotherEntity)));
}
}
UPDATE
In this example hint
hints.Add(new RemoveFieldHint("TestPerformSafely.Model.NS1.MyEntity", "Text"));
works fine, but if I create more complex schema:
Source:
[Serializable]
[HierarchyRoot]
public class MyEntity : Entity, IWithStatus
{
[Field, Key]
public int Id { get; private set; }
[Field(Length = 100)]
public string Text { get; set; }
public Status Status { get; set; }
}
public interface IWithStatus : IEntity
{
[Field]
Status Status { get; set; }
}
[HierarchyRoot]
public class Status : Entity
{
[Field, Key]
public int Id { get; private set; }
[Field(Length = 100)]
public string Text { get; set; }
}
and Destination:
[Serializable]
[HierarchyRoot]
public class AnotherEntity : Entity //, IWithStatus
{
[Field, Key]
public int Id { get; private set; }
[Field(Length = 100)]
public string Text { get; set; }
//public Status Status { get; set; }
}
public interface IWithStatus : IEntity
{
[Field]
Status Status { get; set; }
}
[HierarchyRoot]
public class Status : Entity
{
[Field, Key]
public int Id { get; private set; }
[Field(Length = 100)]
public string Text { get; set; }
}
hint hints.Add(new RemoveFieldHint("TestPerformSafely.Model.NS1.MyEntity", "Status"));
doesn't work, throwing exception
Extracted schema is not equal to the target schema. Details:
Schema comparison result: NotEqual
Has unsafe actions: true
Has column type changes: false
Compatible in ValidateLegacy mode: unknown
Unsafe actions:
RemoveNode, Path=Tables/AnotherEntity/Columns/Status.Id
asked
Sep 23 '11 at 10:19
pil0t
169●25●44