forked from danielgerlag/workflow-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostgresPersistenceProvider.cs
More file actions
48 lines (40 loc) · 1.7 KB
/
PostgresPersistenceProvider.cs
File metadata and controls
48 lines (40 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WorkflowCore.Persistence.EntityFramework.Models;
using WorkflowCore.Persistence.EntityFramework.Services;
namespace WorkflowCore.Persistence.PostgreSQL
{
public class PostgresPersistenceProvider : EntityFrameworkPersistenceProvider
{
private readonly string _connectionString;
public PostgresPersistenceProvider(string connectionString, bool canCreateDB, bool canMigrateDB)
:base(canCreateDB, canMigrateDB)
{
_connectionString = connectionString;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseNpgsql(_connectionString);
}
protected override void ConfigureSubscriptionStorage(EntityTypeBuilder<PersistedSubscription> builder)
{
builder.ForNpgsqlToTable("Subscription", "wfc");
builder.Property(x => x.ClusterKey).ValueGeneratedOnAdd();
}
protected override void ConfigureWorkflowStorage(EntityTypeBuilder<PersistedWorkflow> builder)
{
builder.ForNpgsqlToTable("Workflow", "wfc");
builder.Property(x => x.ClusterKey).ValueGeneratedOnAdd();
}
protected override void ConfigurePublicationStorage(EntityTypeBuilder<PersistedPublication> builder)
{
builder.ForNpgsqlToTable("UnpublishedEvent", "wfc");
builder.Property(x => x.ClusterKey).ValueGeneratedOnAdd();
}
}
}