Skip to content

Commit 4456c32

Browse files
feat: Add Migration Checkpoints to EF Core
- Introduced a new table `MigrationCheckpoints` to track migration states and progress. - Implemented `MigrationCheckpointEntity` to represent the checkpoint data structure. - Added `EFMigrationCheckpointStore` for managing checkpoint data with methods for reading and upserting checkpoints. - Created `MigrationCheckpointConfiguration` for configuring the entity in the DbContext. - Enhanced `ServiceControlDbContext` to include the new `MigrationCheckpoints` DbSet. - Updated `EfCoreExtensions` to provide an `UpsertCheckpoint` method for managing checkpoint persistence. - Added unit tests for `EFMigrationCheckpointStore` and `MigrationCheckpointTable` to ensure correct functionality. - Implemented transaction handling in `MigrationCheckpointTransactionTests` to verify checkpoint behavior during commits and rollbacks. - Updated RavenDB integration to support embedded server readiness checks.
1 parent 909e4bf commit 4456c32

18 files changed

Lines changed: 2619 additions & 4 deletions

‎docs/migration/ravendb-to-sql-migration-instructions.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ The report prints the RavenDB server version, whether the source is embedded or
4444

4545
## If the report fails
4646

47-
The error names the setting to fix:
47+
The error says what to fix:
4848

4949
- **"has no database named ..."**: the database name setting it quotes is wrong.
5050
- **"refused its client certificate access ..."**: grant that certificate Read access to the database, or supply a certificate that has it.
51+
- **"could not start a server for the embedded database ..."**: a ServiceControl instance is still running against that data directory and holds it. Stop the instance, run the report, then start it again.
5152

5253
## Not available yet
5354

‎src/ServiceControl.Persistence.EFCore.PostgreSql/Migrations/20260916125150_AddMigrationCheckpoints.Designer.cs‎

Lines changed: 976 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using Microsoft.EntityFrameworkCore.Migrations;
3+
4+
#nullable disable
5+
6+
namespace ServiceControl.Persistence.EFCore.PostgreSql.Migrations
7+
{
8+
/// <inheritdoc />
9+
public partial class AddMigrationCheckpoints : Migration
10+
{
11+
/// <inheritdoc />
12+
protected override void Up(MigrationBuilder migrationBuilder)
13+
{
14+
migrationBuilder.CreateTable(
15+
name: "migration_checkpoints",
16+
columns: table => new
17+
{
18+
category_id = table.Column<string>(type: "character varying(450)", maxLength: 450, nullable: false),
19+
state = table.Column<int>(type: "integer", nullable: false),
20+
cursor = table.Column<string>(type: "text", nullable: true),
21+
copied_count = table.Column<long>(type: "bigint", nullable: false),
22+
skipped_count = table.Column<long>(type: "bigint", nullable: false),
23+
source_total = table.Column<long>(type: "bigint", nullable: true),
24+
skip_reasons = table.Column<string>(type: "text", nullable: true),
25+
started_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
26+
last_progress_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
27+
settled_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
28+
last_error = table.Column<string>(type: "text", nullable: true),
29+
already_present_count = table.Column<long>(type: "bigint", nullable: false),
30+
version = table.Column<long>(type: "bigint", nullable: false)
31+
},
32+
constraints: table =>
33+
{
34+
table.PrimaryKey("pk_migration_checkpoints", x => x.category_id);
35+
});
36+
}
37+
38+
/// <inheritdoc />
39+
protected override void Down(MigrationBuilder migrationBuilder)
40+
{
41+
migrationBuilder.DropTable(
42+
name: "migration_checkpoints");
43+
}
44+
}
45+
}

‎src/ServiceControl.Persistence.EFCore.PostgreSql/Migrations/PostgreSqlServiceControlDbContextModelSnapshot.cs‎

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)