-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathPostgresqlExtensions.cs
More file actions
61 lines (55 loc) · 3.11 KB
/
Copy pathPostgresqlExtensions.cs
File metadata and controls
61 lines (55 loc) · 3.11 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using DbUp.Builder;
using DbUp.Engine.Transactions;
namespace DBOps.Postgresql
{
public static class PostgresqlExtensions
{
/// <summary>
/// Creates an upgrader for PostgreSQL databases.
/// </summary>
/// <param name="supported">Fluent helper type.</param>
/// <param name="connectionManager">The <see cref="PostgresqlConnectionManager"/> to be used during a database upgrade.</param>
/// <returns>
/// A builder for a database upgrader designed for PostgreSQL databases.
/// </returns>
public static UpgradeEngineBuilder PostgresqlDatabase(this SupportedDatabases supported, IConnectionManager connectionManager)
=> PostgresqlDatabase(connectionManager);
/// <summary>
/// Creates an upgrader for PostgreSQL databases.
/// </summary>
/// <param name="supported">Fluent helper type.</param>
/// <param name="connectionManager">The <see cref="PostgresqlConnectionManager"/> to be used during a database upgrade.</param>
/// <param name="schema">The schema in which to check for changes</param>
/// <returns>
/// A builder for a database upgrader designed for PostgreSQL databases.
/// </returns>
public static UpgradeEngineBuilder PostgresqlDatabase(this SupportedDatabases supported, IConnectionManager connectionManager, string schema)
=> PostgresqlDatabase(connectionManager, schema);
/// <summary>
/// Creates an upgrader for PostgreSQL databases.
/// </summary>
/// <param name="connectionManager">The <see cref="PostgresqlConnectionManager"/> to be used during a database upgrade.</param>
/// <returns>
/// A builder for a database upgrader designed for PostgreSQL databases.
/// </returns>
public static UpgradeEngineBuilder PostgresqlDatabase(IConnectionManager connectionManager)
=> PostgresqlDatabase(connectionManager, null);
/// <summary>
/// Creates an upgrader for PostgreSQL databases.
/// </summary>
/// <param name="connectionManager">The <see cref="PostgresqlConnectionManager"/> to be used during a database upgrade.</param>
/// <param name="schema">The schema in which to check for changes</param>
/// <returns>
/// A builder for a database upgrader designed for PostgreSQL databases.
/// </returns>
public static UpgradeEngineBuilder PostgresqlDatabase(IConnectionManager connectionManager, string schema)
{
var builder = new UpgradeEngineBuilder();
builder.Configure(c => c.ConnectionManager = connectionManager);
builder.Configure(c => c.ScriptExecutor = new PostgresqlScriptExecutor(() => c.ConnectionManager, () => c.Log, schema, () => c.VariablesEnabled, c.ScriptPreprocessors, () => c.Journal));
builder.Configure(c => c.Journal = new PostgresqlTableJournal(() => c.ConnectionManager, () => c.Log, schema, "schemaversions"));
builder.WithPreprocessor(new DbUp.Postgresql.PostgresqlPreprocessor());
return builder;
}
}
}