adding complete db migrations from posgres

This commit is contained in:
2026-10-05 15:57:55 +05:30
parent 9d710349c2
commit 65f58c4000
113 changed files with 24033 additions and 1007 deletions
+9 -5
View File
@@ -17,9 +17,7 @@ using ERPCore.System.Errors;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.OpenApi;
using Npgsql;
using Serilog;
var builder = WebApplication.CreateBuilder(args);
@@ -33,11 +31,17 @@ builder.Host.UseSerilog((ctx, cfg) => cfg
builder.Services.AddControllers()
.AddJsonOptions(o => o.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));
// EF Core + PostgreSQL
// EF Core + MariaDB (Pomelo). The server version is pinned explicitly rather than using
// ServerVersion.AutoDetect: AutoDetect opens a connection, which would make design-time
// commands (`dotnet ef migrations add`) and startup depend on the database being reachable.
// MariaDbServerVersion — not MySqlServerVersion — because the target is MariaDB 10.11, and
// Pomelo changes its SQL translation based on which it is given.
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
?? throw new InvalidOperationException("ConnectionStrings:DefaultConnection is not configured.");
builder.Services.AddDbContext<ErpDbContext>(o =>
{
o.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"));
o.ConfigureWarnings(w => w.Ignore(RelationalEventId.PendingModelChangesWarning));
o.UseMySql(connectionString, new MariaDbServerVersion(new Version(10, 11, 15)));
});
// ProblemDetails (RFC 7807) + domain-exception mapping