You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.5 KiB

using OpenDBDiff.Abstractions.Schema;
using OpenDBDiff.Abstractions.Schema.Model;
using OpenDBDiff.SqlServer.Schema.Model;
namespace OpenDBDiff.SqlServer.Schema.Compare
{
internal class CompareConstraints : CompareBase<Constraint>
{
protected override void DoUpdate<Root>(SchemaList<Constraint, Root> originFields, Constraint node)
{
Constraint origin = originFields[node.FullName];
if (!Constraint.Compare(origin, node))
{
Constraint newNode = (Constraint)node.Clone(originFields.Parent);
if (node.IsDisabled == origin.IsDisabled)
{
newNode.Status = ObjectStatus.Alter;
}
else
newNode.Status = ObjectStatus.Alter + (int)ObjectStatus.Disabled;
originFields[node.FullName] = newNode;
}
else
{
if (node.IsDisabled != origin.IsDisabled)
{
Constraint newNode = (Constraint)node.Clone(originFields.Parent);
newNode.Status = ObjectStatus.Disabled;
originFields[node.FullName] = newNode;
}
}
}
protected override void DoNew<Root>(SchemaList<Constraint, Root> originFields, Constraint node)
{
Constraint newNode = (Constraint)node.Clone(originFields.Parent);
newNode.Status = ObjectStatus.Create;
originFields.Add(newNode);
}
}
}