fix(rd21): guard career and job saves with durable revisions
This commit is contained in:
@@ -15,6 +15,33 @@ public sealed class MigrationChainTests
|
||||
{
|
||||
private const string SnapshotMigration = "20260711181039_SyncModelSnapshot";
|
||||
|
||||
[Fact]
|
||||
public async Task Rd21_revision_upgrade_and_rollback_preserve_existing_job_content()
|
||||
{
|
||||
await using var connection = new SqliteConnection("Data Source=:memory:");
|
||||
await connection.OpenAsync();
|
||||
await using var db = Context(connection);
|
||||
var migrator = db.GetService<IMigrator>();
|
||||
const string previous = "20261021090000_AddDashboardLayoutPreference";
|
||||
await migrator.MigrateAsync(previous);
|
||||
await ExecuteAsync(connection, """
|
||||
INSERT INTO Companies (Name) VALUES ('RD21 migration fixture');
|
||||
INSERT INTO JobApplications
|
||||
(CompanyId, JobTitle, Status, ResponseReceived, OwnerUserId, SavedAt, Notes,
|
||||
HasResume, HasCoverLetter, HasPortfolio, HasOtherAttachment, IsDeleted)
|
||||
VALUES (1, 'Durable role', 'Saved', 0, 'rd21-owner', '2026-10-23', 'Keep these notes', 0, 0, 0, 0, 0);
|
||||
""");
|
||||
await migrator.MigrateAsync();
|
||||
Assert.Equal(1L, await ScalarAsync<long>(connection, "SELECT Version FROM JobApplications WHERE Id=1;"));
|
||||
Assert.Equal("Keep these notes", await ScalarAsync<string>(connection, "SELECT Notes FROM JobApplications WHERE Id=1;"));
|
||||
await migrator.MigrateAsync(previous);
|
||||
Assert.Equal("Durable role", await ScalarAsync<string>(connection, "SELECT JobTitle FROM JobApplications WHERE Id=1;"));
|
||||
Assert.Equal("Keep these notes", await ScalarAsync<string>(connection, "SELECT Notes FROM JobApplications WHERE Id=1;"));
|
||||
Assert.Equal(0L, await ScalarAsync<long>(connection, "SELECT COUNT(*) FROM pragma_table_info('JobApplications') WHERE name='Version';"));
|
||||
await migrator.MigrateAsync();
|
||||
Assert.Equal(1L, await ScalarAsync<long>(connection, "SELECT Version FROM JobApplications WHERE Id=1;"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Blank_sqlite_chain_reaches_latest_and_is_idempotent()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user