protected override void Generate(AlterColumnOperation operation, IModel model, RelationalCommandListBuilder builder) { Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); builder .EndCommand() .Append("ALTER TABLE ") .Append(SqlGenerationHelper.DelimitIdentifier(operation.Table)) .Append(" ALTER COLUMN ") .Append(SqlGenerationHelper.DelimitIdentifier(operation.Name)) .Append(" DROP DEFAULT") .AppendLine(); builder .EndCommand() .Append("ALTER TABLE ") .Append(SqlGenerationHelper.DelimitIdentifier(operation.Table)) .Append(" ALTER COLUMN "); ColumnDefinition( null, operation.Table, operation.Name, operation.ClrType, operation.ColumnType, operation.IsNullable, null /*operation.DefaultValue */, null /*operation.DefaultValueSql */, operation.ComputedColumnSql, operation, model, builder); builder.AppendLine(); if ((operation.DefaultValue != null) || (operation.DefaultValueSql != null)) { builder .EndCommand() .Append("ALTER TABLE ") .Append(SqlGenerationHelper.DelimitIdentifier(operation.Table)) .Append(" ALTER COLUMN ") .Append(SqlGenerationHelper.DelimitIdentifier(operation.Name)) .Append(" SET "); DefaultValue(operation.DefaultValue, operation.DefaultValueSql, builder); } }
protected override void Generate(DropIndexOperation operation, IModel model, RelationalCommandListBuilder builder) { Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); builder .EndCommand() .Append("DROP INDEX ") .Append(SqlGenerationHelper.DelimitIdentifier(operation.Name)); }
public override IReadOnlyList <IRelationalCommand> Generate(IReadOnlyList <MigrationOperation> operations, IModel model = null) { Check.NotNull(operations, nameof(operations)); var builder = new RelationalCommandListBuilder(_commandBuilderFactory); foreach (var operation in operations) { Generate(operation, model, builder); builder .EndCommand(); } return(builder.GetCommands()); }
protected override void Generate(RenameTableOperation operation, IModel model, RelationalCommandListBuilder builder) { Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); if (operation.NewName != null) { builder .EndCommand() .Append("sp_rename N'") .Append(operation.Name) .Append("', N'") .Append(operation.NewName) .Append("'"); } }