Skip to content

Commit 0e5655f

Browse files
Merge pull request #7 from cmdscale/fix/#5_add_custom_operation_support_to_NpgsqlMigrationsSqlGenerator
Fix/#5 add custom operation support to npgsql migrations sql generator
2 parents 4bd6056 + a956653 commit 0e5655f

17 files changed

Lines changed: 890 additions & 95 deletions

‎CmdScale.EntityFrameworkCore.TimescaleDB.Design/Generators/MigrationBuilderSqlHelper.cs‎

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using CmdScale.EntityFrameworkCore.TimescaleDB.Design.Generators;
1+
using CmdScale.EntityFrameworkCore.TimescaleDB.Generators;
22
using CmdScale.EntityFrameworkCore.TimescaleDB.Operations;
33
using Microsoft.EntityFrameworkCore.Infrastructure;
44
using Microsoft.EntityFrameworkCore.Migrations.Design;
@@ -13,30 +13,41 @@ protected override void Generate(MigrationOperation operation, IndentedStringBui
1313
ArgumentNullException.ThrowIfNull(operation);
1414
ArgumentNullException.ThrowIfNull(builder);
1515

16+
HypertableOperationGenerator? hypertableOperationGenerator = null;
17+
ReorderPolicyOperationGenerator? reorderPolicyOperationGenerator = null;
18+
List<string> statements = [];
19+
1620
switch (operation)
1721
{
1822
case CreateHypertableOperation create:
19-
HypertableOperationGenerator.Generate(create, builder);
23+
hypertableOperationGenerator ??= new(isDesignTime: true);
24+
statements = hypertableOperationGenerator.Generate(create);
2025
break;
2126
case AlterHypertableOperation alter:
22-
HypertableOperationGenerator.Generate(alter, builder);
27+
hypertableOperationGenerator ??= new(isDesignTime: true);
28+
statements = hypertableOperationGenerator.Generate(alter);
2329
break;
2430

2531
case AddReorderPolicyOperation addReorder:
26-
ReorderPolicyOperationGenerator.Generate(addReorder, builder);
32+
reorderPolicyOperationGenerator ??= new(isDesignTime: true);
33+
statements = reorderPolicyOperationGenerator.Generate(addReorder);
2734
break;
2835
case AlterReorderPolicyOperation alterReorder:
29-
ReorderPolicyOperationGenerator.Generate(alterReorder, builder);
36+
reorderPolicyOperationGenerator ??= new(isDesignTime: true);
37+
statements = reorderPolicyOperationGenerator.Generate(alterReorder);
3038
break;
3139
case DropReorderPolicyOperation dropReorder:
32-
ReorderPolicyOperationGenerator.Generate(dropReorder, builder);
40+
reorderPolicyOperationGenerator ??= new(isDesignTime: true);
41+
statements = reorderPolicyOperationGenerator.Generate(dropReorder);
3342
break;
3443

35-
default:
44+
default:
3645
base.Generate(operation, builder);
3746
break;
3847
}
48+
49+
SqlBuilderHelper.BuildQueryString(statements, builder);
3950
}
40-
51+
4152
}
42-
}
53+
}

‎CmdScale.EntityFrameworkCore.TimescaleDB.Example/CmdScale.EntityFrameworkCore.TimescaleDB.Example.csproj‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@
1616
<ProjectReference Include="..\CmdScale.EntityFrameworkCore.TimescaleDB.Design\CmdScale.EntityFrameworkCore.TimescaleDB.Design.csproj" />
1717
</ItemGroup>
1818

19+
<ItemGroup>
20+
<Content Include="appsettings.json">
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
</Content>
23+
</ItemGroup>
1924
</Project>

‎CmdScale.EntityFrameworkCore.TimescaleDB.FunctionalTests/CmdScale.EntityFrameworkCore.TimescaleDB.FunctionalTests.csproj‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
</PackageReference>
17-
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.19" />
18-
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="8.0.19" />
19-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
20-
<PackageReference Include="Testcontainers.PostgreSql" Version="4.7.0" />
17+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.21" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="8.0.21" />
19+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
20+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite" Version="9.0.4" />
21+
<PackageReference Include="Npgsql.NetTopologySuite" Version="9.0.4" />
22+
<PackageReference Include="Testcontainers.PostgreSql" Version="4.8.1" />
2123
<PackageReference Include="xunit" Version="2.9.3" />
22-
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
24+
<PackageReference Include="xunit.assert" Version="2.9.3" />
25+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
2326
<PrivateAssets>all</PrivateAssets>
2427
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2528
</PackageReference>

0 commit comments

Comments
 (0)