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.
Connected.Framework/Connected.Data/Schema/Sql/IndexDrop.cs

40 lines
738 B

2 years ago
using System.Text;
namespace Connected.Data.Schema.Sql
{
internal class IndexDrop : TableTransaction
{
public IndexDrop(ObjectIndex index)
{
Index = index;
}
private ObjectIndex Index { get; }
protected override async Task OnExecute()
{
switch (Index.Type)
{
case IndexType.Index:
await Context.Execute(CommandText);
break;
case IndexType.Unique:
case IndexType.PrimaryKey:
await new ConstraintDrop(Index).Execute(Context);
break;
}
}
private string CommandText
{
get
{
var text = new StringBuilder();
text.AppendLine($"DROP INDEX {Index.Name} ON {Escape(Context.Schema.SchemaName(), Context.Schema.Name)};");
return text.ToString();
}
}
}
}