diff --git a/DbUp.Support.SqlServer.Scripting.Console/DbUp.Support.SqlServer.Scripting.Console.csproj b/DbUp.Support.SqlServer.Scripting.Console/DbUp.Support.SqlServer.Scripting.Console.csproj index 498a1df..325d7bb 100644 --- a/DbUp.Support.SqlServer.Scripting.Console/DbUp.Support.SqlServer.Scripting.Console.csproj +++ b/DbUp.Support.SqlServer.Scripting.Console/DbUp.Support.SqlServer.Scripting.Console.csproj @@ -1,76 +1,77 @@ - - - - - Debug - AnyCPU - {80136911-3220-460B-867D-E1C94E241248} - Exe - Properties - DbUp.Support.SqlServer.Scripting.Console - DbUp.Support.SqlServer.Scripting.Console - v4.5 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ../packages/dbup-core.4.1.0/lib/net45/dbup-core.dll - True - - - ../packages/dbup-sqlserver.4.1.0/lib/net35/dbup-sqlserver.dll - True - - - - - - - - - - - - - - - - - - - - {a1ec7074-3c1d-4424-bc80-8bf770758774} - DbUp.Support.SqlServer.Scripting - - - - - - - + + + + + Debug + AnyCPU + {80136911-3220-460B-867D-E1C94E241248} + Exe + Properties + DbUp.Support.SqlServer.Scripting.Console + DbUp.Support.SqlServer.Scripting.Console + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ../packages/dbup-core.4.1.0/lib/net45/dbup-core.dll + True + + + ../packages/dbup-sqlserver.4.1.0/lib/net35/dbup-sqlserver.dll + True + + + + + + + + + + + + + + + + + + + + + {a1ec7074-3c1d-4424-bc80-8bf770758774} + DbUp.Support.SqlServer.Scripting + + + + + + + \ No newline at end of file diff --git a/DbUp.Support.SqlServer.Scripting.Console/Program.cs b/DbUp.Support.SqlServer.Scripting.Console/Program.cs index fba4423..1edc338 100644 --- a/DbUp.Support.SqlServer.Scripting.Console/Program.cs +++ b/DbUp.Support.SqlServer.Scripting.Console/Program.cs @@ -5,6 +5,8 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; +using DbUp.Support.SqlServer.Scripting; +using Microsoft.SqlServer.Management.Smo; class Program { @@ -19,7 +21,17 @@ static int Main(string[] args) .LogToConsole() .Build(); - ScriptingUpgrader upgradeScriptingEngine = new ScriptingUpgrader(connectionString, engine); + Options options = new Options() + { + ScriptingOptions = new ScriptingOptions() + { + ScriptBatchTerminator = true, //include 'GO' statements at the end of script batches + } + }; + + // args = new string[] { "--scriptAllDefinitions" }; + + ScriptingUpgrader upgradeScriptingEngine = new ScriptingUpgrader(connectionString, engine, options); var result = upgradeScriptingEngine.Run(args); if (!result.Successful) diff --git a/DbUp.Support.SqlServer.Scripting/DbObjectScripter.cs b/DbUp.Support.SqlServer.Scripting/DbObjectScripter.cs index 20fa763..7bc90e5 100644 --- a/DbUp.Support.SqlServer.Scripting/DbObjectScripter.cs +++ b/DbUp.Support.SqlServer.Scripting/DbObjectScripter.cs @@ -482,6 +482,10 @@ private void SaveScript(ScriptObject scriptObject, StringCollection script, stri { sb.Append(str); sb.Append(Environment.NewLine); + if (m_options.ScriptingOptions.ScriptBatchTerminator) + { + sb.Append("GO" + Environment.NewLine + Environment.NewLine); + } } m_log.WriteInformation(string.Format("Saving object definition: {0}", Path.Combine(outputDirectory, scriptObject.FileName))); diff --git a/README.md b/README.md index ba5067e..9624498 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,20 @@ +# Changes in this fork: +1. Added support to follow **ScriptBatchTerminator** option so that "Go" statements are added at the end of script batches + +For example +
+ Options options = new Options()
+        {
+            ScriptingOptions = new ScriptingOptions()
+            {
+                ScriptBatchTerminator = true, //include 'GO' statements at the end of script batches
+            }
+        };
+
+        ScriptingUpgrader upgradeScriptingEngine = new ScriptingUpgrader(connectionString, engine, options);
+        var result = upgradeScriptingEngine.Run(args);
+
+ # DbUp SQL Server Object Scripting [![NuGet version](https://badge.fury.io/nu/dbup-sqlserver-scripting.svg)](https://badge.fury.io/nu/dbup-sqlserver-scripting)