This commit is contained in:
StellaOps Bot
2025-11-29 02:19:50 +02:00
parent 2548abc56f
commit b34f13dc03
86 changed files with 9625 additions and 640 deletions

View File

@@ -1,3 +1,4 @@
using System.Reflection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Npgsql;
@@ -75,7 +76,7 @@ public sealed class PostgresFixture : IAsyncDisposable
}
/// <summary>
/// Runs migrations for the test schema.
/// Runs migrations for the test schema from filesystem path.
/// </summary>
/// <param name="migrationsPath">Path to migration SQL files.</param>
/// <param name="moduleName">Module name for logging.</param>
@@ -94,6 +95,41 @@ public sealed class PostgresFixture : IAsyncDisposable
await runner.RunAsync(migrationsPath, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Runs migrations for the test schema from embedded resources in an assembly.
/// </summary>
/// <param name="assembly">Assembly containing embedded migration resources.</param>
/// <param name="moduleName">Module name for logging.</param>
/// <param name="resourcePrefix">Optional prefix to filter resources.</param>
/// <param name="cancellationToken">Cancellation token.</param>
public async Task RunMigrationsFromAssemblyAsync(
Assembly assembly,
string moduleName,
string? resourcePrefix = null,
CancellationToken cancellationToken = default)
{
var runner = new MigrationRunner(
_connectionString,
_schemaName,
moduleName,
_logger);
await runner.RunFromAssemblyAsync(assembly, resourcePrefix, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Runs migrations for the test schema from embedded resources using a type from the assembly.
/// </summary>
/// <typeparam name="TAssemblyMarker">Type from the assembly containing migrations.</typeparam>
/// <param name="moduleName">Module name for logging.</param>
/// <param name="resourcePrefix">Optional prefix to filter resources.</param>
/// <param name="cancellationToken">Cancellation token.</param>
public Task RunMigrationsFromAssemblyAsync<TAssemblyMarker>(
string moduleName,
string? resourcePrefix = null,
CancellationToken cancellationToken = default)
=> RunMigrationsFromAssemblyAsync(typeof(TAssemblyMarker).Assembly, moduleName, resourcePrefix, cancellationToken);
/// <summary>
/// Executes raw SQL for test setup.
/// </summary>