using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using StellaOps.Infrastructure.Postgres.Migrations;
using StellaOps.Infrastructure.Postgres.Options;
using StellaOps.VexHub.Core;
using StellaOps.VexHub.Persistence.Postgres;
using StellaOps.VexHub.Persistence.Postgres.Repositories;
namespace StellaOps.VexHub.Persistence.Extensions;
///
/// Service collection extensions for VexHub persistence.
///
public static class VexHubPersistenceExtensions
{
///
/// Adds VexHub PostgreSQL persistence services to the service collection.
///
public static IServiceCollection AddVexHubPersistence(
this IServiceCollection services,
IConfiguration configuration)
{
services.Configure(configuration.GetSection("Postgres"));
services.AddSingleton();
services.AddStartupMigrations(
VexHubDataSource.DefaultSchemaName,
"VexHub.Persistence",
typeof(VexHubDataSource).Assembly);
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
return services;
}
///
/// Adds VexHub PostgreSQL persistence services with explicit options.
///
public static IServiceCollection AddVexHubPersistence(
this IServiceCollection services,
Action configureOptions)
{
services.Configure(configureOptions);
services.AddSingleton();
services.AddStartupMigrations(
VexHubDataSource.DefaultSchemaName,
"VexHub.Persistence",
typeof(VexHubDataSource).Assembly);
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
services.AddScoped();
return services;
}
}