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