Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class MigrationContextFactory : IDesignTimeDbContextFactory<PostgresConte
{
public PostgresContext CreateDbContext(string[] args)
{
return new PostgresContext(@"Server=127.0.0.1;Port=5432;Database=workflow;User Id=postgres;Password=password;");
return new PostgresContext(@"Server=127.0.0.1;Port=5432;Database=workflow;User Id=postgres;Password=password;","wfc");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ namespace WorkflowCore.Persistence.PostgreSQL
public class PostgresContext : WorkflowDbContext
{
private readonly string _connectionString;
private readonly string _schemaName;

public PostgresContext(string connectionString)
public PostgresContext(string connectionString,string schemaName)
:base()
{
_connectionString = connectionString;
_schemaName = schemaName;
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
Expand All @@ -27,37 +29,37 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

protected override void ConfigureSubscriptionStorage(EntityTypeBuilder<PersistedSubscription> builder)
{
builder.ToTable("Subscription", "wfc");
builder.ToTable("Subscription", _schemaName);
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
}

protected override void ConfigureWorkflowStorage(EntityTypeBuilder<PersistedWorkflow> builder)
{
builder.ToTable("Workflow", "wfc");
builder.ToTable("Workflow", _schemaName);
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
}

protected override void ConfigureExecutionPointerStorage(EntityTypeBuilder<PersistedExecutionPointer> builder)
{
builder.ToTable("ExecutionPointer", "wfc");
builder.ToTable("ExecutionPointer", _schemaName);
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
}

protected override void ConfigureExecutionErrorStorage(EntityTypeBuilder<PersistedExecutionError> builder)
{
builder.ToTable("ExecutionError", "wfc");
builder.ToTable("ExecutionError", _schemaName);
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
}

protected override void ConfigureExetensionAttributeStorage(EntityTypeBuilder<PersistedExtensionAttribute> builder)
{
builder.ToTable("ExtensionAttribute", "wfc");
builder.ToTable("ExtensionAttribute", _schemaName);
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
}

protected override void ConfigureEventStorage(EntityTypeBuilder<PersistedEvent> builder)
{
builder.ToTable("Event", "wfc");
builder.ToTable("Event", _schemaName);
builder.Property(x => x.PersistenceId).ValueGeneratedOnAdd();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ namespace WorkflowCore.Persistence.PostgreSQL
public class PostgresContextFactory : IWorkflowDbContextFactory
{
private readonly string _connectionString;
private readonly string _schemaName;

public PostgresContextFactory(string connectionString)
public PostgresContextFactory(string connectionString, string schemaName)
{
_connectionString = connectionString;
_schemaName = schemaName;
}

public WorkflowDbContext Build()
{
return new PostgresContext(_connectionString);
return new PostgresContext(_connectionString,_schemaName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
public static WorkflowOptions UsePostgreSQL(this WorkflowOptions options, string connectionString, bool canCreateDB, bool canMigrateDB)
public static WorkflowOptions UsePostgreSQL(this WorkflowOptions options,
string connectionString, bool canCreateDB, bool canMigrateDB, string schemaName="wfc")
{
options.UsePersistence(sp => new EntityFrameworkPersistenceProvider(new PostgresContextFactory(connectionString), canCreateDB, canMigrateDB));
options.UsePersistence(sp => new EntityFrameworkPersistenceProvider(new PostgresContextFactory(connectionString, schemaName), canCreateDB, canMigrateDB));
return options;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<Description>Provides support to persist workflows running on Workflow Core to a PostgreSQL database.</Description>
<Version>2.0.0</Version>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.0.0.0</FileVersion>
<Version>2.0.1</Version>
<AssemblyVersion>2.0.1.0</AssemblyVersion>
<FileVersion>2.0.1.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class PostgresPersistenceProviderFixture : BasePersistenceFixture
public PostgresPersistenceProviderFixture(PostgresDockerSetup dockerSetup, ITestOutputHelper output)
{
output.WriteLine($"Connecting on {PostgresDockerSetup.ConnectionString}");
_subject = new EntityFrameworkPersistenceProvider(new PostgresContextFactory(PostgresDockerSetup.ConnectionString), true, true);
_subject = new EntityFrameworkPersistenceProvider(new PostgresContextFactory(PostgresDockerSetup.ConnectionString,"wfc"), true, true);
_subject.EnsureStoreExists();
}
}
Expand Down