Keeps SQLite migration temporary storage in memory

This commit is contained in:
BinaryAlley committed 2026-10-26 22:05:07 +02:00
1 parent 02bcf91661
commit 73ed952ded
1 file changed
+13 -1
+13 -1
View File
@@ -94,7 +94,19 @@ public class Program
try
{
LuminaDbContext context = services.GetRequiredService<LuminaDbContext>();
await context.Database.MigrateAsync();
// Migrations can need a temporary store for an update or a table rebuild. The process can run in an environment whose
// temporary directory is missing or read-only, so the migration connection keeps the temporary store in memory instead
// of failing with SQLite error 14 while it tries to create a temporary file.
await context.Database.OpenConnectionAsync();
try
{
await context.Database.ExecuteSqlRawAsync("PRAGMA temp_store = MEMORY;");
await context.Database.MigrateAsync();
}
finally
{
await context.Database.CloseConnectionAsync();
}
// Enable the Write-Ahead Logging journal mode and a busy timeout, so that the Entity Framework connection and the dedicated connections
// used by the bulk data access operations of Dapper can access the database concurrently, without database locking errors.