fix(database): qualify RD21 saves against pinned MariaDB 12.2.2
This commit is contained in:
@@ -97,31 +97,7 @@ builder.Services.AddDbContext<JobTrackerContext>((sp, options) =>
|
||||
var cfg = sp.GetRequiredService<IConfiguration>();
|
||||
var paths = sp.GetRequiredService<AppPaths>();
|
||||
|
||||
var provider = (cfg["Database:Provider"] ?? "sqlite").Trim().ToLowerInvariant();
|
||||
var cs = cfg.GetConnectionString("JobTracker");
|
||||
if (string.IsNullOrWhiteSpace(cs))
|
||||
{
|
||||
cs = $"Data Source={paths.GetDbPath()}";
|
||||
provider = "sqlite";
|
||||
}
|
||||
|
||||
if (provider is "mysql" or "mariadb")
|
||||
{
|
||||
// Avoid ServerVersion.AutoDetect here because it forces an immediate DB connection
|
||||
// during service registration, which can crash the API if MariaDB is temporarily
|
||||
// unavailable or on a different network during deploy startup.
|
||||
options.UseMySql(cs, new MariaDbServerVersion(new Version(11, 0, 0)), mysql =>
|
||||
{
|
||||
mysql.MigrationsAssembly("JobTrackerApi");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
options.UseSqlite(cs, sqlite =>
|
||||
{
|
||||
sqlite.MigrationsAssembly("JobTrackerApi");
|
||||
});
|
||||
}
|
||||
DatabaseConfiguration.Configure(options, cfg, paths.GetDbPath());
|
||||
|
||||
// We create Identity tables on startup in environments where `dotnet ef` isn't available.
|
||||
// That can cause EF to detect "pending model changes" and throw on Migrate(). Ignore it.
|
||||
|
||||
Reference in New Issue
Block a user