Skip to content

Commit

Permalink
[release/9.0] Don't execute empty batches (dotnet#34870)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriySvyryd committed Oct 14, 2024
1 parent d67ca8e commit ae85c4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1426,8 +1426,11 @@ protected override void Generate(SqlOperation operation, IModel? model, Migratio

void AppendBatch(string batch)
{
builder.Append(batch);
EndStatement(builder, operation.SuppressTransaction);
if (!string.IsNullOrWhiteSpace(batch))
{
builder.Append(batch);
EndStatement(builder, operation.SuppressTransaction);
}
}
}

Expand Down Expand Up @@ -2524,7 +2527,7 @@ private IReadOnlyList<MigrationOperation> RewriteOperations(
{
// for create table we always generate new temporal information from the operation itself
// just in case there was a table with that name before that got deleted/renamed
// this shouldn't happen as we re-use existin tables rather than drop/recreate
// this shouldn't happen as we re-use existing tables rather than drop/recreate
// but we are being extra defensive here
// and also, temporal state (disabled versioning etc.) should always reset when creating a table
temporalInformation = BuildTemporalInformationFromMigrationOperation(schema, createTableOperation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ SELECT @Counter
SELECT GetDate()
GO
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'00000000000004_Migration4', N'7.0.0-test');
GO
Expand Down Expand Up @@ -299,9 +296,6 @@ SELECT @Counter
SELECT GetDate()
GO
GO
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'00000000000004_Migration4', N'7.0.0-test');
GO
Expand Down

0 comments on commit ae85c4b

Please sign in to comment.