public override void Generate( DropSequenceOperation dropSequenceOperation, IndentedStringBuilder stringBuilder) { throw new NotSupportedException(Strings.FormatMigrationOperationNotSupported( GetType(), dropSequenceOperation.GetType())); }
protected virtual void Generate([NotNull] DropSequenceOperation operation, [NotNull] IndentedStringBuilder builder) { Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); builder.Append(".DropSequence("); if (operation.Schema != null) { builder.Append("name: "); } builder.Append(_code.Literal(operation.Name)); if (operation.Schema != null) { builder .Append(", schema: ") .Append(_code.Literal(operation.Schema)); } builder.Append(")"); using (builder.Indent()) { Annotations(operation.Annotations, builder); } }
public override void Visit(DropSequenceOperation dropSequenceOperation, DatabaseModel databaseModel) { Check.NotNull(dropSequenceOperation, "dropSequenceOperation"); Check.NotNull(databaseModel, "databaseModel"); databaseModel.RemoveSequence(dropSequenceOperation.SequenceName); }
public void Create_and_initialize_operation() { var dropSequenceOperation = new DropSequenceOperation("dbo.MySequence"); Assert.Equal("dbo.MySequence", dropSequenceOperation.SequenceName); Assert.True(dropSequenceOperation.IsDestructiveChange); }
public void Generate_with_drop_sequence_is_not_supported() { var operation = new DropSequenceOperation("EpisodeSequence"); Assert.Equal( Strings.FormatMigrationOperationNotSupported(typeof(SQLiteMigrationOperationSqlGenerator), operation.GetType()), Assert.Throws <NotSupportedException>(() => Generate(operation)).Message); }
public void Generate_with_drop_sequence_is_noop() { var operation = new DropSequenceOperation("EpisodeSequence"); var sql = Generate(operation); Assert.Empty(sql); }
public virtual void Generate([NotNull] DropSequenceOperation dropSequenceOperation, [NotNull] IndentedStringBuilder stringBuilder, bool generateIdempotentSql) { Check.NotNull(dropSequenceOperation, "dropSequenceOperation"); stringBuilder .Append("DROP SEQUENCE ") .Append(DelimitIdentifier(dropSequenceOperation.SequenceName)); }
public virtual void Generate([NotNull] DropSequenceOperation dropSequenceOperation, [NotNull] SqlBatchBuilder batchBuilder) { Check.NotNull(dropSequenceOperation, "dropSequenceOperation"); Check.NotNull(batchBuilder, "batchBuilder"); batchBuilder .Append("DROP SEQUENCE ") .Append(DelimitIdentifier(dropSequenceOperation.SequenceName)); }
public static OperationBuilderSurface <DropSequenceOperation> DropSequence(this IMigrationBuilder builder, string name, string schema = null, string catalog = null) { var op = new DropSequenceOperation { Name = new ObjectName(catalog, schema, name) }; builder.AddOperation(op); return(new OperationBuilderSurface <DropSequenceOperation>(op)); }
public void Dispatches_visitor() { var dropSequenceOperation = new DropSequenceOperation("dbo.MySequence"); var mockVisitor = MigrationsTestHelpers.MockSqlGenerator(); var builder = new Mock <SqlBatchBuilder>(); dropSequenceOperation.GenerateSql(mockVisitor.Object, builder.Object); mockVisitor.Verify(g => g.Generate(dropSequenceOperation, builder.Object), Times.Once()); }
public void Generate_when_drop_sequence_operation() { var operation = new DropSequenceOperation("dbo.MySequence"); Assert.Equal( @"DropSequence(""dbo.MySequence"")", CSharpMigrationCodeGenerator.Generate(operation)); GenerateAndValidateCode(operation); }
public override void Generate([NotNull] DropSequenceOperation dropSequenceOperation, [NotNull] IndentedStringBuilder stringBuilder) { Check.NotNull(dropSequenceOperation, "dropSequenceOperation"); Check.NotNull(stringBuilder, "stringBuilder"); stringBuilder .Append("DropSequence(") .Append(GenerateLiteral(dropSequenceOperation.SequenceName)) .Append(")"); }
public void Dispatches_visitor() { var dropSequenceOperation = new DropSequenceOperation("dbo.MySequence"); var mockVisitor = new Mock <MigrationOperationSqlGenerator>(new RelationalTypeMapper()); var builder = new Mock <IndentedStringBuilder>(); dropSequenceOperation.GenerateSql(mockVisitor.Object, builder.Object); mockVisitor.Verify(g => g.Generate(dropSequenceOperation, builder.Object), Times.Once()); }
public async Task DropSequence() { var operation = new DropSequenceOperation() { Name = "MySequence", }; var batch = await Generate(new[] { operation }); Assert.AreEqual(1, batch.Count()); Assert.AreEqual(NewLineEnd(@"DROP SEQUENCE ""MySequence"";"), batch[0].CommandText); }
public virtual void Generate( [NotNull] DropSequenceOperation operation, [CanBeNull] IModel model, [NotNull] SqlBatchBuilder builder) { Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); builder .Append("DROP SEQUENCE ") .Append(_sql.DelimitIdentifier(operation.Name, operation.Schema)); }
protected virtual void Generate( [NotNull] DropSequenceOperation operation, [CanBeNull] IModel model, [NotNull] RelationalCommandListBuilder builder) { Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); builder .Append("DROP SEQUENCE ") .Append(SqlGenerator.DelimitIdentifier(operation.Name, operation.Schema)); }
public void Visit_with_drop_sequence_operation() { var model = new DatabaseModel(); var operation = new DropSequenceOperation("dbo.MySequence"); model.AddSequence(new Sequence("dbo.MySequence")); Assert.Equal(1, model.Sequences.Count); operation.Accept(new DatabaseModelModifier(), model); Assert.Equal(0, model.Sequences.Count); }
public virtual OperationBuilder <DropSequenceOperation> DropSequence(string name, string schema = null) { Check.NotEmpty(name, nameof(name)); var operation = new DropSequenceOperation { Schema = schema, Name = name }; Operations.Add(operation); return(new OperationBuilder <DropSequenceOperation>(operation)); }
/// <summary> /// 删除序列号。 /// </summary> /// <param name="operation">操作实例。</param> /// <param name="builder"><see cref="MigrationCommandListBuilder"/>实例对象。</param> protected virtual void Generate( [NotNull] DropSequenceOperation operation, [NotNull] MigrationCommandListBuilder builder) { Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); builder .Append("DROP SEQUENCE ") .Append(SqlHelper.DelimitIdentifier(operation.Name, operation.Schema)) .AppendLine(SqlHelper.StatementTerminator); EndStatement(builder); }
public override void Generate(DropSequenceOperation dropSequenceOperation, IndentedStringBuilder stringBuilder, bool generateIdempotentSql) { Check.NotNull(dropSequenceOperation, "dropSequenceOperation"); Check.NotNull(stringBuilder, "stringBuilder"); if (generateIdempotentSql) { GenerateSequencePresenceCheck(dropSequenceOperation.SequenceName, negative: false, builder: stringBuilder); using (stringBuilder.AppendLine().Indent()) { base.Generate(dropSequenceOperation, stringBuilder, generateIdempotentSql: false); } } else { base.Generate(dropSequenceOperation, stringBuilder, generateIdempotentSql); } }
public virtual void Visit(DropSequenceOperation dropSequenceOperation, DatabaseModel databaseModel) { databaseModel.RemoveSequence(dropSequenceOperation.SequenceName); }
public override void Generate(DropSequenceOperation dropSequenceOperation, IndentedStringBuilder stringBuilder) { }
protected override void Generate(DropSequenceOperation operation, IModel model, MigrationCommandListBuilder builder) { throw new NotSupportedException(SqliteStrings.SequencesNotSupported); }
protected override void Generate(DropSequenceOperation operation, IModel model, RelationalCommandListBuilder builder) { throw new NotSupportedException("SQL Server Compact does not support sequences."); }
protected override void Generate(DropSequenceOperation operation, IModel model, MigrationCommandListBuilder builder) { throw new NotSupportedException(string.Format(NotSupported, operation.GetType().Name)); }
public abstract void Generate([NotNull] DropSequenceOperation dropSequenceOperation, [NotNull] IndentedStringBuilder stringBuilder);
protected override List <MigrationOperation> GetOperations() { List <MigrationOperation> operations = new List <MigrationOperation>(); if (this.DeletedIndexes != null) { foreach (var index in DeletedIndexes) { var _DropIndexOperation = new DropIndexOperation(); _DropIndexOperation.Table = this.OldTableName.ToLower(); _DropIndexOperation.Name = EF_CreateTable_Action.GetIndexName(index.Keys.Split(','), this.TableId); operations.Add(_DropIndexOperation); } } if (this.DeletedColumns != null) { foreach (var column in this.DeletedColumns) { var _DropColumnOperation = new DropColumnOperation() { Name = column.Name, Table = this.OldTableName.ToLower(), }; operations.Add(_DropColumnOperation); } } if (this.ChangedColumns != null) { foreach (var column in this.ChangedColumns) { if (column.ChangedProperties["Name"] != null) { var _RenameColumnOperation = new RenameColumnOperation() { Name = column.ChangedProperties["Name"].OriginalValue.ToString().ToLower(), NewName = column.Name.ToLower(), Table = this.OldTableName.ToLower(), }; operations.Add(_RenameColumnOperation); } if (column.ChangedProperties["IsAutoIncrement"] != null) { var original = (bool)column.ChangedProperties["IsAutoIncrement"].OriginalValue; if (original) { var _DropSequenceOperation = new DropSequenceOperation() { Name = column.Name, }; operations.Add(_DropSequenceOperation); } else { var _CreateSequenceOperation = new CreateSequenceOperation() { StartValue = 1, Name = column.Name, }; operations.Add(_CreateSequenceOperation); } } if (column.ChangedProperties["IsPKID"] != null) { var original = (bool)column.ChangedProperties["IsPKID"].OriginalValue; if (original) { var _DropPrimaryKeyOperation = new DropPrimaryKeyOperation() { Name = column.Name, Table = this.OldTableName.ToLower(), }; operations.Add(_DropPrimaryKeyOperation); } else { var _AddPrimaryKeyOperation = new AddPrimaryKeyOperation() { Columns = new string[] { column.Name }, Table = this.OldTableName.ToLower(), }; operations.Add(_AddPrimaryKeyOperation); } } if (column.ChangedProperties.Any(m => m.Key != "Name" && m.Key != "IsAutoIncrement" && m.Key != "IsPKID") == false) { continue; } var olddbtype = column.dbType; if (column.ChangedProperties["dbType"] != null) { olddbtype = column.ChangedProperties["dbType"].OriginalValue.ToString(); } var oldDefaultValue = column.defaultValue; if (column.ChangedProperties["defaultValue"] != null) { oldDefaultValue = column.ChangedProperties["defaultValue"].OriginalValue.ToString(); } string oldComputedColumnSql = null; var oldlength = column.length; if (column.ChangedProperties["length"] != null) { oldlength = column.ChangedProperties["length"].OriginalValue.ToString(); } if (!string.IsNullOrEmpty(oldlength)) { //借用ComputedColumnSql字段存放length oldComputedColumnSql = oldlength; } var _AlterColumnOperation = new AlterColumnOperation() { Table = this.OldTableName.ToLower(), ClrType = EF_CreateTable_Action.GetCSharpType(column.dbType), ColumnType = column.dbType, DefaultValue = column.defaultValue, IsNullable = column.CanNull.GetValueOrDefault(), Name = column.Name.ToLower(), OldColumn = new ColumnOperation() { ClrType = EF_CreateTable_Action.GetCSharpType(olddbtype), ColumnType = olddbtype, DefaultValue = oldDefaultValue, ComputedColumnSql = oldComputedColumnSql, }, }; if (!string.IsNullOrEmpty(column.length)) { //借用ComputedColumnSql字段存放length _AlterColumnOperation.ComputedColumnSql = column.length; } operations.Add(_AlterColumnOperation); } } if (this.NewTableName.ToLower() != this.OldTableName.ToLower()) { var _RenameTableOperation = new RenameTableOperation() { Name = OldTableName.ToLower(), NewName = NewTableName.ToLower(), }; operations.Add(_RenameTableOperation); } if (this.NewColumns != null) { foreach (var column in this.NewColumns) { var _AddColumnOperation = new AddColumnOperation() { Table = this.NewTableName.ToLower(), ClrType = EF_CreateTable_Action.GetCSharpType(column.dbType), ColumnType = column.dbType, DefaultValue = column.defaultValue, IsUnicode = true, IsNullable = column.CanNull.GetValueOrDefault(), Name = column.Name.ToLower(), }; if (!string.IsNullOrEmpty(column.length)) { //借用ComputedColumnSql字段存放length _AddColumnOperation.ComputedColumnSql = column.length; } operations.Add(_AddColumnOperation); } } if (this.NewIndexes != null) { foreach (var indexCfg in this.NewIndexes) { var keynames = indexCfg.Keys.Split(','); var _CreateIndexOperation = new CreateIndexOperation(); _CreateIndexOperation.Table = this.NewTableName.ToLower(); _CreateIndexOperation.Name = EF_CreateTable_Action.GetIndexName(keynames, this.TableId); _CreateIndexOperation.Columns = keynames.Select(m => m.ToLower()).ToArray(); _CreateIndexOperation.IsUnique = indexCfg.IsUnique.GetValueOrDefault(); operations.Add(_CreateIndexOperation); } } return(operations); }
protected override void Generate(DropSequenceOperation operation, IModel model, MigrationCommandListBuilder builder) => base.Generate(operation, model, builder);
protected override void Generate(DropSequenceOperation operation, IModel model, MigrationCommandListBuilder builder) { throw new NotSupportedException("JET does not support sequences"); }
protected override void Generate(DropSequenceOperation operation, IModel model, SqlBatchBuilder builder) { throw new NotSupportedException(Strings.SequencesNotSupported); }