File tree 2 files changed +24
-6
lines changed
2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 10
10
var connectionString = new Option < string > ( new [ ] { "-c" , "--connection-string" } , description : "Connection string to target database" ) ;
11
11
connectionString . IsRequired = true ;
12
12
13
+ var nonTransactional = new Option < bool > ( new [ ] { "--non-transactional" } , "Create a transaction per scripts" ) ;
14
+
13
15
command . AddOption ( connectionString ) ;
14
16
command . AddOption ( scriptDirectory ) ;
17
+ command . AddOption ( nonTransactional ) ;
15
18
16
- command . SetHandler ( EmptyClass . Run , connectionString , scriptDirectory ) ;
19
+ command . SetHandler ( Worker . Run , connectionString , scriptDirectory , nonTransactional ) ;
17
20
18
21
var parser = new CommandLineBuilder ( command )
19
22
. UseHelp ( )
Original file line number Diff line number Diff line change 5
5
6
6
namespace SimpleDbUp ;
7
7
8
- public class EmptyClass
8
+ public class Worker
9
9
{
10
- public static void Run ( string connectionString , string scriptsPath )
10
+ public static void Run (
11
+ string connectionString ,
12
+ string scriptsPath ,
13
+ bool nonTransactional
14
+ )
11
15
{
16
+ Console . WriteLine ( "Running the upgrade using" +
17
+ $ "{ Environment . NewLine } \t Connection String: { connectionString . Length } chars" +
18
+ $ "{ Environment . NewLine } \t Scripts Path: { new DirectoryInfo ( scriptsPath ) . Name } " +
19
+ $ "{ Environment . NewLine } \t Non transactional: { nonTransactional } ") ;
20
+
12
21
try
13
22
{
14
23
EnsureDatabase . For . MySqlDatabase ( connectionString ) ;
@@ -18,7 +27,7 @@ public static void Run(string connectionString, string scriptsPath)
18
27
ExitWithError ( exception ) ;
19
28
}
20
29
21
- var upgrade = DeployChanges . To
30
+ var builder = DeployChanges . To
22
31
. MySqlDatabase ( connectionString )
23
32
. WithScriptsFromFileSystem (
24
33
scriptsPath ,
@@ -28,8 +37,14 @@ public static void Run(string connectionString, string scriptsPath)
28
37
ScriptType = DbUp . Support . ScriptType . RunOnce
29
38
} )
30
39
. LogToConsole ( )
31
- . LogScriptOutput ( )
32
- . Build ( ) ;
40
+ . LogScriptOutput ( ) ;
41
+
42
+ if ( nonTransactional )
43
+ builder . WithTransactionPerScript ( ) ;
44
+ else
45
+ builder . WithTransaction ( ) ;
46
+
47
+ var upgrade = builder . Build ( ) ;
33
48
34
49
var result = upgrade . PerformUpgrade ( ) ;
35
50
You can’t perform that action at this time.
0 commit comments