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(); } } } }