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's gravatar image

pil0t
207575763

edited Sep 26 '11 at 02:50


One Answer:

Fixed in 7799 (04e97c6dc75a)

answered Oct 03 '11 at 11:42

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA