Preserve the shared SQLite schema while resetting
Some checks failed
Dotnet build and test / build (pull_request) Failing after 9m27s

This commit is contained in:
Paul Schneider 2026-11-23 16:00:31 +00:00
commit 56f9ad3706
Signed by: notazof
GPG key ID: AD4B9B545FBD7D12
2 changed files with 9 additions and 5 deletions

View file

@ -36,6 +36,8 @@
### Fixed ### Fixed
* [Yavsc.Api/Tests] Preserve the shared SQLite schema while resetting API integration-test data, preventing hosted workers from observing missing `LiveFlow` tables during test-host shutdown.
* [PostIt/Blogs] Keep a newly created post readable when its creation response temporarily omits author details, and include the author in server-side create/detail payloads so relative resource URLs can be resolved after save. * [PostIt/Blogs] Keep a newly created post readable when its creation response temporarily omits author details, and include the author in server-side create/detail payloads so relative resource URLs can be resolved after save.
* [PostIt/Capture] Automatically upload finalized screen recordings as `video/mp4` to `Mes fichiers / screencast`, streaming the multipart file from disk and retaining the local copy if the upload fails. * [PostIt/Capture] Automatically upload finalized screen recordings as `video/mp4` to `Mes fichiers / screencast`, streaming the multipart file from disk and retaining the local copy if the upload fails.

View file

@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Data.Sqlite; using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -377,7 +376,10 @@ public sealed class ApiWebServerFixture : WebHostFixture
return; return;
} }
// EnsureDeleted cannot clear a shared in-memory database kept alive by the anchor. // Keep the schema in place while the hosted workers are running. Dropping and
// recreating every table exposes a race where a worker queries LiveFlow
// between those operations and faults; Host.StopAsync later rethrows that
// fault when the shared test host shuts down.
db.Database.OpenConnection(); db.Database.OpenConnection();
try try
{ {
@ -397,9 +399,11 @@ public sealed class ApiWebServerFixture : WebHostFixture
command.Transaction = transaction.GetDbTransaction(); command.Transaction = transaction.GetDbTransaction();
foreach (var table in tables) foreach (var table in tables)
{ {
command.CommandText = $"DROP TABLE \"{table.Replace("\"", "\"\"")}\";"; command.CommandText = $"DELETE FROM \"{table.Replace("\"", "\"\"")}\";";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
command.CommandText = "DELETE FROM sqlite_sequence;";
command.ExecuteNonQuery();
transaction.Commit(); transaction.Commit();
} }
finally finally
@ -413,8 +417,6 @@ public sealed class ApiWebServerFixture : WebHostFixture
{ {
db.Database.CloseConnection(); db.Database.CloseConnection();
} }
// SQLite retains sqlite_sequence, so EnsureCreated would incorrectly see an existing schema.
db.GetService<IRelationalDatabaseCreator>().CreateTables();
} }
public void ResetAndSeedRdvQueryGraph() public void ResetAndSeedRdvQueryGraph()