public override void Execute(DocumentStore store) { store.Database.RawExecute(new SqlBuilder() .Append($"alter table {store.Database.FormatTableNameAndEscape(Tablename)} add {store.Database.Escape(Column.Name)}") .Append(DdlCommandEx.BuildColumnSql(Column)) .ToString()); }
public override void Execute(DocumentStore store) { if (!Table.Columns.Any()) { throw new InvalidOperationException("Cannot create a table with no columns."); } var sql = new SqlBuilder() .Append($"if not ({DdlCommandEx.BuildTableExistsSql(store, Table.Name)})") .Append($"begin create table {store.Database.FormatTableNameAndEscape(Table.Name)} ("); foreach (var(column, i) in Table.Columns.Select((column, i) => (column, i))) { sql.Append(new SqlBuilder() .Append(i > 0, ",") .Append(store.Database.Escape(column.Name)) .Append(DdlCommandEx.BuildColumnSql(column))); } sql.Append(") end;"); store.Database.RawExecute(sql.ToString(), schema: true); }