-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use postgres module for storage
- Loading branch information
Showing
2 changed files
with
21 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 2 additions & 23 deletions
25
src/Sitko.Core.Storage.Metadata.Postgres/PostgresStorageMetadataModule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,11 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Options; | ||
using Sitko.Core.App; | ||
using Sitko.Core.Storage.Metadata.Postgres.DB; | ||
|
||
namespace Sitko.Core.Storage.Metadata.Postgres; | ||
namespace Sitko.Core.Storage.Metadata.Postgres; | ||
|
||
public class | ||
PostgresStorageMetadataModule<TStorageOptions> : BaseStorageMetadataModule<TStorageOptions, | ||
PostgresStorageMetadataProvider<TStorageOptions>, PostgresStorageMetadataModuleOptions<TStorageOptions>> | ||
where TStorageOptions : StorageOptions | ||
{ | ||
public override string OptionsKey => $"Storage:Metadata:Postgres:{typeof(TStorageOptions).Name}"; | ||
public override string[] OptionKeys => new[] { "Storage:Metadata:Postgres:Default", OptionsKey }; | ||
|
||
public override void ConfigureServices(IApplicationContext applicationContext, IServiceCollection services, | ||
PostgresStorageMetadataModuleOptions<TStorageOptions> startupOptions) | ||
{ | ||
base.ConfigureServices(applicationContext, services, startupOptions); | ||
services.AddDbContextFactory<StorageDbContext>((serviceProvider, builder) => | ||
{ | ||
var options = serviceProvider | ||
.GetRequiredService<IOptions<PostgresStorageMetadataModuleOptions<TStorageOptions>>>(); | ||
builder.UseNpgsql(options.Value.GetConnectionString(), optionsBuilder => | ||
{ | ||
optionsBuilder.MigrationsHistoryTable("__EFMigrationsHistory", StorageDbContext.Schema); | ||
}); | ||
}); | ||
} | ||
public override string[] OptionKeys => ["Storage:Metadata:Postgres:Default", OptionsKey]; | ||
} | ||
|