using System.Text; namespace Connected.Data.Schema.Sql { internal class PrimaryKeyAdd : ColumnTransaction { public PrimaryKeyAdd(ISchemaColumn column) : base(column) { } protected override async Task OnExecute() { await Context.Execute(CommandText); } private string CommandText { get { var text = new StringBuilder(); text.AppendLine($"ALTER TABLE {Escape(Context.Schema.SchemaName(), Context.Schema.Name)}"); text.AppendLine($"ADD CONSTRAINT {Context.GenerateConstraintName(Context.Schema.SchemaName(), Context.Schema.Name, ConstraintNameType.PrimaryKey)}"); text.AppendLine($"PRIMARY KEY CLUSTERED ({Escape(Column.Name)}) ON {Escape(SchemaExtensions.FileGroup)}"); return text.ToString(); } } } }