Skip to content

Commit

Permalink
Consolidate terminate overloads in MigrationsSqlGenerator
Browse files Browse the repository at this point in the history
Closes #16654
  • Loading branch information
roji committed Jul 20, 2019
1 parent 2f235e9 commit 28fe450
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 244 deletions.
171 changes: 11 additions & 160 deletions src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,6 @@ protected virtual void Generate(
generateAction(this, operation, model, builder);
}

/// <summary>
/// Builds commands for the given <see cref="AddColumnOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />, and then terminates the final command.
/// </summary>
/// <param name="operation"> The operation. </param>
/// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
/// <param name="builder"> The command builder to use to build the commands. </param>
protected virtual void Generate(
[NotNull] AddColumnOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder)
=> Generate(operation, model, builder, terminate: true);

/// <summary>
/// Builds commands for the given <see cref="AddColumnOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />.
Expand All @@ -178,7 +165,7 @@ protected virtual void Generate(
[NotNull] AddColumnOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder,
bool terminate)
bool terminate = true)
{
Check.NotNull(operation, nameof(operation));
Check.NotNull(builder, nameof(builder));
Expand All @@ -204,19 +191,6 @@ protected virtual void Generate(
}
}

/// <summary>
/// Builds commands for the given <see cref="AddForeignKeyOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />, and then terminates the final command.
/// </summary>
/// <param name="operation"> The operation. </param>
/// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
/// <param name="builder"> The command builder to use to build the commands. </param>
protected virtual void Generate(
[NotNull] AddForeignKeyOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder)
=> Generate(operation, model, builder, terminate: true);

/// <summary>
/// Builds commands for the given <see cref="AddForeignKeyOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />.
Expand All @@ -229,7 +203,7 @@ protected virtual void Generate(
[NotNull] AddForeignKeyOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder,
bool terminate)
bool terminate = true)
{
Check.NotNull(operation, nameof(operation));
Check.NotNull(builder, nameof(builder));
Expand All @@ -248,19 +222,6 @@ protected virtual void Generate(
}
}

/// <summary>
/// Builds commands for the given <see cref="AddPrimaryKeyOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />, and then terminates the final command.
/// </summary>
/// <param name="operation"> The operation. </param>
/// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
/// <param name="builder"> The command builder to use to build the commands. </param>
protected virtual void Generate(
[NotNull] AddPrimaryKeyOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder)
=> Generate(operation, model, builder, terminate: true);

/// <summary>
/// Builds commands for the given <see cref="AddPrimaryKeyOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />.
Expand All @@ -273,7 +234,7 @@ protected virtual void Generate(
[NotNull] AddPrimaryKeyOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder,
bool terminate)
bool terminate = true)
{
Check.NotNull(operation, nameof(operation));
Check.NotNull(builder, nameof(builder));
Expand Down Expand Up @@ -469,19 +430,6 @@ protected virtual void Generate(
throw new NotImplementedException();
}

/// <summary>
/// Builds commands for the given <see cref="CreateIndexOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />, and then terminates the final command.
/// </summary>
/// <param name="operation"> The operation. </param>
/// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
/// <param name="builder"> The command builder to use to build the commands. </param>
protected virtual void Generate(
[NotNull] CreateIndexOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder)
=> Generate(operation, model, builder, terminate: true);

/// <summary>
/// Builds commands for the given <see cref="CreateIndexOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />.
Expand All @@ -494,7 +442,7 @@ protected virtual void Generate(
[NotNull] CreateIndexOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder,
bool terminate)
bool terminate = true)
{
Check.NotNull(operation, nameof(operation));
Check.NotNull(builder, nameof(builder));
Expand Down Expand Up @@ -589,19 +537,6 @@ protected virtual void Generate(
EndStatement(builder);
}

/// <summary>
/// Builds commands for the given <see cref="CreateTableOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />, and then terminates the final command.
/// </summary>
/// <param name="operation"> The operation. </param>
/// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
/// <param name="builder"> The command builder to use to build the commands. </param>
protected virtual void Generate(
[NotNull] CreateTableOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder)
=> Generate(operation, model, builder, terminate: true);

/// <summary>
/// Builds commands for the given <see cref="CreateTableOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />.
Expand All @@ -614,7 +549,7 @@ protected virtual void Generate(
[NotNull] CreateTableOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder,
bool terminate)
bool terminate = true)
{
Check.NotNull(operation, nameof(operation));
Check.NotNull(builder, nameof(builder));
Expand Down Expand Up @@ -645,19 +580,6 @@ protected virtual void Generate(
}
}

/// <summary>
/// Builds commands for the given <see cref="DropColumnOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />, and then terminates the final command.
/// </summary>
/// <param name="operation"> The operation. </param>
/// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
/// <param name="builder"> The command builder to use to build the commands. </param>
protected virtual void Generate(
[NotNull] DropColumnOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder)
=> Generate(operation, model, builder, terminate: true);

/// <summary>
/// Builds commands for the given <see cref="DropColumnOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />.
Expand All @@ -670,7 +592,7 @@ protected virtual void Generate(
[NotNull] DropColumnOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder,
bool terminate)
bool terminate = true)
{
Check.NotNull(operation, nameof(operation));
Check.NotNull(builder, nameof(builder));
Expand All @@ -688,19 +610,6 @@ protected virtual void Generate(
}
}

/// <summary>
/// Builds commands for the given <see cref="DropForeignKeyOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />, and then terminates the final command.
/// </summary>
/// <param name="operation"> The operation. </param>
/// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
/// <param name="builder"> The command builder to use to build the commands. </param>
protected virtual void Generate(
[NotNull] DropForeignKeyOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder)
=> Generate(operation, model, builder, terminate: true);

/// <summary>
/// Builds commands for the given <see cref="DropForeignKeyOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />.
Expand All @@ -713,7 +622,7 @@ protected virtual void Generate(
[NotNull] DropForeignKeyOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder,
bool terminate)
bool terminate = true)
{
Check.NotNull(operation, nameof(operation));
Check.NotNull(builder, nameof(builder));
Expand All @@ -731,25 +640,6 @@ protected virtual void Generate(
}
}

/// <summary>
/// <para>
/// Can be overridden by database providers to build commands for the given <see cref="DropIndexOperation" />
/// by making calls on the given <see cref="MigrationCommandListBuilder" />.
/// </para>
/// <para>
/// Note that the default implementation of this method throws <see cref="NotImplementedException" />. Providers
/// must override if they are to support this kind of operation.
/// </para>
/// </summary>
/// <param name="operation"> The operation. </param>
/// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
/// <param name="builder"> The command builder to use to build the commands. </param>
protected virtual void Generate(
[NotNull] DropIndexOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder)
=> Generate(operation, model, builder, terminate: true);

/// <summary>
/// <para>
/// Can be overridden by database providers to build commands for the given <see cref="DropIndexOperation" />
Expand All @@ -768,24 +658,11 @@ protected virtual void Generate(
[NotNull] DropIndexOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder,
bool terminate)
bool terminate = true)
{
throw new NotImplementedException();
}

/// <summary>
/// Builds commands for the given <see cref="DropPrimaryKeyOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />, and then terminates the final command.
/// </summary>
/// <param name="operation"> The operation. </param>
/// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
/// <param name="builder"> The command builder to use to build the commands. </param>
protected virtual void Generate(
[NotNull] DropPrimaryKeyOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder)
=> Generate(operation, model, builder, terminate: true);

/// <summary>
/// Builds commands for the given <see cref="DropPrimaryKeyOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />.
Expand All @@ -798,7 +675,7 @@ protected virtual void Generate(
[NotNull] DropPrimaryKeyOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder,
bool terminate)
bool terminate = true)
{
Check.NotNull(operation, nameof(operation));
Check.NotNull(builder, nameof(builder));
Expand Down Expand Up @@ -862,19 +739,6 @@ protected virtual void Generate(
EndStatement(builder);
}

/// <summary>
/// Builds commands for the given <see cref="DropTableOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />, and then terminates the final command.
/// </summary>
/// <param name="operation"> The operation. </param>
/// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
/// <param name="builder"> The command builder to use to build the commands. </param>
protected virtual void Generate(
[NotNull] DropTableOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder)
=> Generate(operation, model, builder, terminate: true);

/// <summary>
/// Builds commands for the given <see cref="DropTableOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />.
Expand All @@ -887,7 +751,7 @@ protected virtual void Generate(
[NotNull] DropTableOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder,
bool terminate)
bool terminate = true)
{
Check.NotNull(operation, nameof(operation));
Check.NotNull(builder, nameof(builder));
Expand Down Expand Up @@ -1042,19 +906,6 @@ protected virtual void Generate(
EndStatement(builder, operation.SuppressTransaction);
}

/// <summary>
/// Builds commands for the given <see cref="InsertDataOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />, and then terminates the final command.
/// </summary>
/// <param name="operation"> The operation. </param>
/// <param name="model"> The target model which may be <c>null</c> if the operations exist without a model. </param>
/// <param name="builder"> The command builder to use to build the commands. </param>
protected virtual void Generate(
[NotNull] InsertDataOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder)
=> Generate(operation, model, builder, terminate: true);

/// <summary>
/// Builds commands for the given <see cref="InsertDataOperation" /> by making calls on the given
/// <see cref="MigrationCommandListBuilder" />.
Expand All @@ -1067,7 +918,7 @@ protected virtual void Generate(
[NotNull] InsertDataOperation operation,
[CanBeNull] IModel model,
[NotNull] MigrationCommandListBuilder builder,
bool terminate)
bool terminate = true)
{
Check.NotNull(operation, nameof(operation));
Check.NotNull(builder, nameof(builder));
Expand Down
Loading

0 comments on commit 28fe450

Please sign in to comment.