[FA-11] I'm getting sick of fusion but I dont see better alternatives
Some checks failed
Release / build-and-push (map[dockerfile:FictionArchive.API/Dockerfile name:api]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.AuthenticationService/Dockerfile name:authentication-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.FileService/Dockerfile name:file-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.NovelService/Dockerfile name:novel-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.SchedulerService/Dockerfile name:scheduler-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.TranslationService/Dockerfile name:translation-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.UserService/Dockerfile name:user-service]) (pull_request) Has been cancelled
Release / build-frontend (pull_request) Has been cancelled
Build Gateway / build-subgraphs (map[name:novel-service project:FictionArchive.Service.NovelService subgraph:Novel]) (pull_request) Failing after 51s
Build Gateway / build-subgraphs (map[name:translation-service project:FictionArchive.Service.TranslationService subgraph:Translation]) (pull_request) Has been cancelled
Build Gateway / build-subgraphs (map[name:user-service project:FictionArchive.Service.UserService subgraph:User]) (pull_request) Has been cancelled
Build Gateway / build-gateway (pull_request) Has been cancelled
Build Gateway / build-subgraphs (map[name:scheduler-service project:FictionArchive.Service.SchedulerService subgraph:Scheduler]) (pull_request) Has been cancelled
CI / build-frontend (pull_request) Has been cancelled
CI / build-backend (pull_request) Has been cancelled
Some checks failed
Release / build-and-push (map[dockerfile:FictionArchive.API/Dockerfile name:api]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.AuthenticationService/Dockerfile name:authentication-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.FileService/Dockerfile name:file-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.NovelService/Dockerfile name:novel-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.SchedulerService/Dockerfile name:scheduler-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.TranslationService/Dockerfile name:translation-service]) (pull_request) Has been cancelled
Release / build-and-push (map[dockerfile:FictionArchive.Service.UserService/Dockerfile name:user-service]) (pull_request) Has been cancelled
Release / build-frontend (pull_request) Has been cancelled
Build Gateway / build-subgraphs (map[name:novel-service project:FictionArchive.Service.NovelService subgraph:Novel]) (pull_request) Failing after 51s
Build Gateway / build-subgraphs (map[name:translation-service project:FictionArchive.Service.TranslationService subgraph:Translation]) (pull_request) Has been cancelled
Build Gateway / build-subgraphs (map[name:user-service project:FictionArchive.Service.UserService subgraph:User]) (pull_request) Has been cancelled
Build Gateway / build-gateway (pull_request) Has been cancelled
Build Gateway / build-subgraphs (map[name:scheduler-service project:FictionArchive.Service.SchedulerService subgraph:Scheduler]) (pull_request) Has been cancelled
CI / build-frontend (pull_request) Has been cancelled
CI / build-backend (pull_request) Has been cancelled
This commit is contained in:
@@ -6,16 +6,29 @@ namespace FictionArchive.Service.Shared.Extensions;
|
||||
|
||||
public static class DatabaseExtensions
|
||||
{
|
||||
public static IServiceCollection RegisterDbContext<TContext>(this IServiceCollection services,
|
||||
string connectionString) where TContext : FictionArchiveDbContext
|
||||
public static IServiceCollection RegisterDbContext<TContext>(
|
||||
this IServiceCollection services,
|
||||
string connectionString,
|
||||
bool skipInfrastructure = false) where TContext : FictionArchiveDbContext
|
||||
{
|
||||
services.AddDbContext<TContext>(options =>
|
||||
if (skipInfrastructure)
|
||||
{
|
||||
options.UseNpgsql(connectionString, o =>
|
||||
// For schema export: use in-memory provider to allow EF Core entity discovery
|
||||
services.AddDbContext<TContext>(options =>
|
||||
{
|
||||
o.UseNodaTime();
|
||||
options.UseInMemoryDatabase($"SchemaExport_{typeof(TContext).Name}");
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddDbContext<TContext>(options =>
|
||||
{
|
||||
options.UseNpgsql(connectionString, o =>
|
||||
{
|
||||
o.UseNodaTime();
|
||||
});
|
||||
});
|
||||
}
|
||||
return services;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.11">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
22
FictionArchive.Service.Shared/SchemaExportDetector.cs
Normal file
22
FictionArchive.Service.Shared/SchemaExportDetector.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace FictionArchive.Service.Shared;
|
||||
|
||||
/// <summary>
|
||||
/// Detects if the application is running in schema export mode (for HotChocolate CLI commands).
|
||||
/// In this mode, infrastructure like RabbitMQ and databases should not be initialized.
|
||||
/// </summary>
|
||||
public static class SchemaExportDetector
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if the current run is a schema export command.
|
||||
/// </summary>
|
||||
/// <param name="args">Command line arguments passed to Main()</param>
|
||||
/// <returns>True if running schema export, false otherwise</returns>
|
||||
public static bool IsSchemaExportMode(string[] args)
|
||||
{
|
||||
// HotChocolate CLI pattern: "schema export" after "--" delimiter
|
||||
// Handles: dotnet run -- schema export --output schema.graphql
|
||||
var normalizedArgs = args.SkipWhile(a => a == "--").ToArray();
|
||||
return normalizedArgs.Length > 0 &&
|
||||
normalizedArgs[0].Equals("schema", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user