diff --git a/CHANGELOG.md b/CHANGELOG.md index b622f56..f2e00c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.3.20] - 2026-04-26 + +### Fixed + +- **FluentMigrator DI:** **`AddFluentMigratorCore`** registers a default **`IVersionTableMetaDataAccessor`**; **`WithVersionTable`** on **`ConfigureRunner`** could still leave **`VersionInfo`** in use. Engine registration now removes any prior **`IVersionTableMetaDataAccessor`** descriptors and registers **`PassThroughVersionTableMetaDataAccessor`** for **`CertsFluentMigratorVersionTableMetaData`** so **`MigrateUp`** always targets **`version_info`**. + ## [3.3.19] - 2026-04-26 ### Changed diff --git a/src/MaksIT.CertsUI.Engine/Extensions/ServiceCollectionExtensions.cs b/src/MaksIT.CertsUI.Engine/Extensions/ServiceCollectionExtensions.cs index 64063fa..372e72c 100644 --- a/src/MaksIT.CertsUI.Engine/Extensions/ServiceCollectionExtensions.cs +++ b/src/MaksIT.CertsUI.Engine/Extensions/ServiceCollectionExtensions.cs @@ -1,4 +1,5 @@ using FluentMigrator.Runner; +using FluentMigrator.Runner.Initialization; using Microsoft.Extensions.DependencyInjection; using MaksIT.CertsUI.Engine.DomainServices; using MaksIT.CertsUI.Engine.FluentMigrations; @@ -25,15 +26,21 @@ public static class ServiceCollectionExtensions { if (string.IsNullOrWhiteSpace(certsEngineConfiguration.ConnectionString)) throw new ArgumentException("Certs engine connection string is required for FluentMigrator (empty string uses connectionless/preview mode and will not create tables).", nameof(certsEngineConfiguration)); - // FluentMigrator: IRunMigrationsService invoked from Program.cs before RunAsync. Use .For.All() so version metadata - // and migration discovery match in-process runner expectations (see FluentMigrator docs / #1062). + // FluentMigrator: IRunMigrationsService invoked from Program.cs before RunAsync. Use .For.All() so migration discovery + // matches in-process runner expectations (see FluentMigrator docs / #1062). + // Version table: AddFluentMigratorCore registers a default IVersionTableMetaDataAccessor; replace it so public.version_info + // is always used (ConfigureRunner's WithVersionTable alone can lose to that default depending on DI resolution order). services.AddFluentMigratorCore() .ConfigureRunner(rb => rb .AddPostgres() .WithGlobalConnectionString(certsEngineConfiguration.ConnectionString) - .WithVersionTable(new CertsFluentMigratorVersionTableMetaData()) .ScanIn(typeof(BaselineCertsSchema).Assembly).For.All()) .AddLogging(lb => lb.AddFluentMigratorConsole()); + + foreach (var d in services.Where(x => x.ServiceType == typeof(IVersionTableMetaDataAccessor)).ToList()) + services.Remove(d); + services.AddSingleton( + new PassThroughVersionTableMetaDataAccessor(new CertsFluentMigratorVersionTableMetaData())); services.AddScoped(); services.AddScoped(); diff --git a/src/MaksIT.CertsUI/MaksIT.CertsUI.csproj b/src/MaksIT.CertsUI/MaksIT.CertsUI.csproj index 2f97ea8..46e4d2d 100644 --- a/src/MaksIT.CertsUI/MaksIT.CertsUI.csproj +++ b/src/MaksIT.CertsUI/MaksIT.CertsUI.csproj @@ -1,7 +1,7 @@ - 3.3.19 + 3.3.20 net10.0 enable enable