diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ebf3322 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.nupkg +nuget.exe diff --git a/DbUp.Support.SqlServer.Scripting.Console/App.config b/DbUp.Support.SqlServer.Scripting.Console/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting.Console/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file 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 new file mode 100644 index 0000000..d3ef877 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting.Console/DbUp.Support.SqlServer.Scripting.Console.csproj @@ -0,0 +1,68 @@ + + + + + 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.3.2.1\lib\NET35\DbUp.dll + + + + + + + + + + + + + + + + + + + + {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 new file mode 100644 index 0000000..d01b3bd --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting.Console/Program.cs @@ -0,0 +1,40 @@ +using DbUp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +class Program +{ + static int Main(string[] args) + { + var connectionString = + args.FirstOrDefault() + ?? "Server=(local)\\SqlExpress; Database=MyApp; Trusted_connection=true"; + + var engine = + DeployChanges.To + .SqlDatabase(connectionString) + .WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly()) + .LogToConsole() + .Build(); + + ScriptingUpgrader upgradeScriptingEngine = new ScriptingUpgrader(engine); + var result = upgradeScriptingEngine.PerformUpgrade(args); + + if (!result.Successful) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(result.Error); + Console.ResetColor(); + return -1; + } + + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("Success!"); + Console.ResetColor(); + return 0; + } +} \ No newline at end of file diff --git a/DbUp.Support.SqlServer.Scripting.Console/Properties/AssemblyInfo.cs b/DbUp.Support.SqlServer.Scripting.Console/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9ee54c7 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting.Console/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("DbUp.Support.SqlServer.Scripting.Console")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("DbUp.Support.SqlServer.Scripting.Console")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("417fce9f-c246-4230-991d-77a46d7a634f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.exe b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.exe new file mode 100644 index 0000000..202e6e0 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.exe differ diff --git a/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.exe.config b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.exe.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.pdb b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.pdb new file mode 100644 index 0000000..54fed77 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.pdb differ diff --git a/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.vshost.exe b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.vshost.exe new file mode 100644 index 0000000..666c0af Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.vshost.exe differ diff --git a/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.vshost.exe.config b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.vshost.exe.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.vshost.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.vshost.exe.manifest b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.vshost.exe.manifest new file mode 100644 index 0000000..061c9ca --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.Console.vshost.exe.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.dll b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.dll new file mode 100644 index 0000000..e581c29 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.dll differ diff --git a/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.pdb b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.pdb new file mode 100644 index 0000000..4210924 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.Support.SqlServer.Scripting.pdb differ diff --git a/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.dll b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.dll new file mode 100644 index 0000000..ccf14aa Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.dll differ diff --git a/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.xml b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.xml new file mode 100644 index 0000000..e1d4579 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting.Console/bin/Debug/DbUp.xml @@ -0,0 +1,1334 @@ + + + + DbUp + + + + + Configuration extensions for the standard stuff. + + + + + Logs to a custom logger. + + + The logger. + + The same builder + + + + + Logs to the console using pretty colours. + + The builder. + + The same builder + + + + + Logs to the console using pretty colours. + + The builder. + + The same builder + + + + + Logs to System.Diagnostics.Trace. + + The builder. + + The same builder + + + + + Uses a custom journal for recording which scripts were executed. + + The builder. + The custom journal. + + The same builder + + + + + Adds a custom script provider to the upgrader. + + The builder. + The script provider. + + The same builder + + + + + Adds a static set of scripts to the upgrader. + + The builder. + The scripts. + + The same builder + + + + + Adds a static set of scripts to the upgrader. + + The builder. + The scripts. + + The same builder + + + + + Adds a single static script to the upgrader. + + The builder. + The script. + + The same builder + + + + + Adds a single static script to the upgrader. + + The builder. + The name of the script. This should never change once executed. + The script body. + + The same builder + + + + + Adds all scripts from a folder on the file system. + + The builder. + The directory path. + + The same builder + + + + + Adds all scripts from a folder on the file system, with a custom filter. + + The builder. + The directory path. + The filter. Use the static class to get some pre-defined filters. + + The same builder + + + + + Adds all scripts found as embedded resources in the given assembly. + + The builder. + The assembly. + + The same builder + + + + + Adds all scripts found as embedded resources in the given assembly, with a custom filter (you'll need to exclude non- .SQL files yourself). + + The builder. + The assembly. + The filter. Don't forget to ignore any non- .SQL files. + + The same builder + + + + + Adds all scripts found as embedded resources in the given assembly, or classes which inherit from IScript, with a custom filter (you'll need to exclude non- .SQL files yourself). + + The builder. + The assembly. + + The same builder + + + + + Adds all scripts found as embedded resources in the given assembly, or classes which inherit from IScript, with a custom filter (you'll need to exclude non- .SQL files yourself). + + The builder. + The assembly. + The Sql Script filter (only affects embdeeded scripts, does not filter IScript files). Don't forget to ignore any non- .SQL files. + + The same builder + + + + + Adds a preprocessor that can replace portions of a script. + + The builder. + The preprocessor. + + The same builder + + + + + Adds a set of variables that will be replaced before scripts are executed. + + The builder. + The variables. + + The same builder + + + + + Adds a single variable that will be replaced before scripts are executed. + + The builder. + The name of the variable. + The value to be substituted. + + + + + Sets a configuration flag which will cause the engine to skip variable expansion. + + The builder. + + + + + Sets a configuration flag which will cause the engine to perform variable expansion. + + The builder. + + + + + Allows you to set the execution timeout for scripts. + + The builder. + A TimeSpan value containing the timeout value or null. + The timeout value is less than zero or greater than 2,147,483,647 seconds. + Setting the timeout parameter to null will use the default timeout of the underlying provider. + + + + + Run creates a new connection for each script, without a transaction + + + + + + + Run DbUp in a single transaction + + + + + + + Run each script in it's own transaction + + + + + + + Represents the configuration of an UpgradeEngine. + + + + + Initializes a new instance of the class. + + + + + Ensures all expectations have been met regarding this configuration. + + + + + Adds variables to the configuration which will be substituted for every script + + The variables + + + + Manages your database connections, allowing you to control the use of transactions and the behaviour of those transactions + + + + + Gets or sets a log which captures details about the upgrade. + + + + + Gets a mutable list of script providers. + + + + + Gets a mutable list of script pre-processors. + + + + + Gets or sets the journal, which tracks the scripts that have already been run. + + + + + Gets or sets the script executor, which runs scripts against the underlying database. + + + + + A collection of variables to be replaced in scripts before they are run + + + + + Determines if variables should be replaced in scripts before they are run. + + + + + Builds a UpgradeEngine by accepting a list of callbacks to execute. For custom configuration, you should + implement extension methods on top of this class. + + + + + Adds a callback that will be run to configure the upgrader when Build is called. + + The configuration. + + + + Creates an UpgradeEngine based on this configuration. + + + + + + A fluent builder for creating database upgraders. + + + + + Returns the databases supported by DbUp. + + + + + Manages Sql Database Connections + + + + + Allows you to run an operation with a managed connection + + + + + Tells the connection manager it is starting an operation + + + + + Execute a lambda with the connection managed by the connection manager (i.e transactions, reusing connections etc) + + Action to execute + + + + Execute a lambda with the connection managed by the connection manager (i.e transactions, reusing connections etc) + + Action to execute + + + + Scripts often have multiple statements which have to be executed in their own commands. + + For example, MSSQL splits on GO, SQLite splits on ; etc. + + + + + Specifies the transaction strategy + + + + + Specifies whether the db script output should be logged + + + + + Manages Database Connections + + + + + Creates a database connection for the current database engine + + + + + Tells the connection manager is starting + + + + + Executes an action using the specfied transaction mode + + The action to execute + + + + Executes an action which has a result using the specfied transaction mode + + The action to execute + The result type + The result of the command + + + + Splits a script into commands, for example SQL Server separates command by the GO statement + + The script + A list of SQL Commands + + + + The transaction strategy that DbUp should use + + + + + Specifies whether the db script output should be logged + + + + + A class which represents a script, allowing you to dynamically generate a sql script at runtime + + + + + Provides the Sql Script to execute + + A factory to create open and active database commands + The Sql Script contents + + + + The transaction strategy being to be used by the DatabaseConnectionManager + + + + + Executes an action + + + + + + Executes an action which has a result + + + + + + + + Initialises the transaction strategy with the upgrade log + + + + + Represents a SQL Server script that is fetched at execution time, rather than discovery time + + + + + Represents a SQL Server script that comes from an embedded resource in an assembly. + + + + + Initializes a new instance of the class. + + The name. + The contents. + + + + + + + + + + + + + + + + + + + Gets the contents of the script. + + + + + + Gets the name of the script. + + + + + + Initializes a new instance of the class. + + The name. + The delegate which creates the content at execution time. + + + + Gets the contents of the script. + + + + + + Used for database engines that do not support schema's, it will remove $schema$. from all scripts + + + + + Preprocessor that executes before scripts are executed against the database + + + + + Performs some proprocessing step on a script + + + + + Performs some proprocessing step on a script + + + + + The transaction strategy to use + + + + + Run creates a new connection for each script, without a transaction + + + + + DbUp will run using a single transaction for the whole upgrade operation + + + + + DbUp will create a new connection and transaction per script + + + + + A factory class for filter methods. + + + + + This filter will exclude scripts that are listed in a file. + + + The file should contain a single script name per line. + + The file that contains the script names to be excluded, one per line. + + + + + This filter will only include scripts that are listed in a file. All other scripts will be excluded. + + + The file should contain a single script name per line. + + The file that contains the script names to be included, one per line. + + + + + This filter will exclude the specified scripts. + + The names of the scripts to be excluded. + + + + + This filter will include only the specified scripts, and exclude any others. + + The names of the scripts to be included. + + + + + Enables multiple executions of idempotent scripts. + + + + + This interface is provided to allow different projects to store version information differently. + + + + + Recalls the version number of the database. + + + + + + Records an upgrade script for a database. + + The script. + + + + Returns an empty array of length 0 + + + + + + Does not store the script, simply returns + + + + + + An implementation of the interface which tracks version numbers for a + Firebird database using a table called SchemaVersions. + + + + + Creates a new Firebird table journal. + + The Firebird connection manager. + The upgrade logger. + The name of the journal table. + + + + Fetches the list of already executed scripts. + + + + + + Records an upgrade script for a database. + + The script. + + + + An implementation of the interface which tracks version numbers for a + PostgreSQL database using a table called SchemaVersions. + + + + + Creates a new MySql table journal. + + The MySql connection manager. + The upgrade logger. + The name of the schema the journal is stored in. + The name of the journal table. + + + + Records an upgrade script for a database. + + The script. + + + + An implementation of the interface which tracks version numbers for a + PostgreSQL database using a table called SchemaVersions. + + + + + Creates a new PostgreSQL table journal. + + The PostgreSQL connection manager. + The upgrade logger. + The name of the schema the journal is stored in. + The name of the journal table. + + + + Records an upgrade script for a database. + + The script. + + + + Responsible for splitting SQL text into a list of commands. + + + + + Returns the seperate executable SQL commands within the SQL script. + + + + + + + Manages Sql Database Connections + + + + + Manages Sql Database Connections + + + + + + A helper for executing SQL queries easily. + + + + + Initializes a new instance of the class. + + The command factory. + The schema. + The additional script preprocessors. + Sets the variablesEnabled setting to true. + + + + Initializes a new instance of the class. + + The command factory. + The schema. + Function indicating true if variables should be replaced, false otherwise. + The additional script preprocessors. + + + + Adds a variable to be substituted on Adhoc script + + + + + + + + Executes a scalar query. + + The query. + The parameters. + + + + + Executes a query that returns the number of records modified. + + The query. + The parameters. + + + + + Executes a select query or procedure. + + The query. + The parameters. + + + + + Database Schema, should be null if database does not support schemas + + + + + A log that writes to the console in a colorful way. + + + + + Implemented by objects which record the internal details of the database migration. + + + + + Writes an informational message to the log. + + The format. + The args. + + + + Writes an error message to the log. + + The format. + The args. + + + + Writes a warning message to the log. + + The format. + The args. + + + + Writes an informational message to the log. + + The format. + The args. + + + + Writes an error message to the log. + + The format. + The args. + + + + Writes a warning message to the log. + + The format. + The args. + + + + This class orchestrates the database upgrade process. + + + + + Initializes a new instance of the class. + + The configuration. + + + + Determines whether the database is out of date and can be upgraded. + + + + + Tries to connect to the database. + + Any error message encountered. + + + + + Performs the database upgrade. + + + + + Returns a list of scripts that will be executed when the upgrade is performed + + The scripts to be executed + + + + Creates version record for any new migration scripts without executing them. + Useful for bringing development environments into sync with automated environments + + + + + + Represents the results of a database upgrade. + + + + + Initializes a new instance of the class. + + The scripts that were executed. + if set to true [successful]. + The error. + + + + Gets the scripts that were executed. + + + + + Gets a value indicating whether this is successful. + + + + + Gets the error. + + + + + This interface is implemented by classes that execute upgrade scripts against a database. + + + + + Executes the specified script against a database at a given connection string. + + The script. + + + + Executes the specified script against a database at a given connection string. + + The script. + Variables to replace in the script + + + + Verifies the specified schema exists and is valid + + + + + Timeout for each section of the script in seconds. If not set, the default timeout for the executor is used. + + + + + An enhanced implementation which retrieves upgrade scripts or IScript code upgrade scripts embedded in an assembly. + + + + + Provides scripts to be executed. + + + + + Gets all scripts that should be executed. + + + + + Initializes a new instance of the class. + + The assembly. + The embedded sql script filter. + + + + Gets all scripts that should be executed. + + + + + Allows backwards compatibility with previous API/behaviour of using connection factories with DbUp + + + + + Ctor for LegacySqlConnectionManager + + The connectionFactory + + + + No options are set. + + + + + Remove starting and ending white space from the object name. + + + + + Quotes the name of the SQLite object in square brackets to allow Special characters in the object name. + + Name of the object to quote. + The quoted object name with trimmed whitespace + + + + Quotes the name of the SQLite object in square brackets to allow Special characters in the object name. + + Name of the object to quote. + The settings which indicate if the whitespace should be dropped or not. + The quoted object name + + + + An implementation of the interface which tracks version numbers for a + SQLite database using a table called SchemaVersions. + + + + + An implementation of the interface which tracks version numbers for a + SQL Server database using a table called dbo.SchemaVersions. + + + + + Initializes a new instance of the class. + + The connection manager. + The log. + The schema that contains the table. + The table name. + + var journal = new TableJournal("Server=server;Database=database;Trusted_Connection=True", "dbo", "MyVersionTable"); + + + + + Recalls the version number of the database. + + All executed scripts. + + + + The Sql which gets + + + + + Records a database upgrade for a database specified in a given connection string. + + The script. + + + + The sql to exectute to create the schema versions table + + + + + + + Initializes a new instance of the class. + + + + + Create table sql for SQLite + + + + + + + Parses Sql Objects and performs quoting functions + + + + + Quotes the name of the SQL object in square brackets to allow Special characters in the object name. + This function implements System.Data.SqlClient.SqlCommandBuilder.QuoteIdentifier() with an additional + validation which is missing from the SqlCommandBuilder version. + + Name of the object to quote. + The quoted object name with trimmed whitespace + + + + Quotes the name of the SQL object in square brackets to allow Special characters in the object name. + This function implements System.Data.SqlClient.SqlCommandBuilder.QuoteIdentifier() with an additional + validation which is missing from the SqlCommandBuilder version. + + Name of the object to quote. + The settings which indicate if the whitespace should be dropped or not. + The quoted object name + + + + A standard implementation of the IScriptExecutor interface that executes against a SQL Server + database. + + + + + Initializes an instance of the class. + + + The logging mechanism. + The schema that contains the table. + Function that returns true if variables should be replaced, false otherwise. + Script Preprocessors in addition to variable substitution + + + + Executes the specified script against a database at a given connection string. + + The script. + + + + Verifies the existence of targeted schema. If schema is not verified, will check for the existence of the dbo schema. + + + + + Executes the specified script against a database at a given connection string. + + The script. + Variables to replace in the script + + + + SQLCommand Timeout in seconds. If not set, the default SQLCommand timeout is not changed. + + + + + Database Schema, should be null if database does not support schemas + + + + + Substitutes variables for values in SqlScripts + + + + + Initializes a new instance of the class. + + The variables. + + + + Substitutes variables + + + + + + Allows you to easily programatically supply scripts from code. + + + + + Initializes a new instance of the class. + + The scripts. + + + + Gets all scripts that should be executed. + + + + + The default implementation which retrieves upgrade scripts embedded in an assembly. + + + + + Initializes a new instance of the class. + + The assembly. + The filter. + + + + Gets all scripts that should be executed. + + + + + + Alternate implementation which retrieves upgrade scripts via a directory + + + + + + Path to SQL upgrade scripts + + + + + Path to SQL upgrade scripts + The filter. + + + + Gets all scripts that should be executed. + + + + + Used to create databases that are deleted at the end of a unit test. + + + + + Creates new TemporarySqlDatabase against (local) + + + + + Initializes a new instance of the class. + + The name. + + + + Creates the database. + + + + + Deletes the database. + + + + + Gets the connection string. + + The connection string. + + + + Gets a tool to run ad-hoc SQL queries. + + The ad hoc. + + + + A log that writes to System.Diagnostics.Trace. + + + + + Writes an informational message to the log. + + The format. + The args. + + + + Writes an error message to the log. + + The format. + The args. + + + + Writes a warning message to the log. + + The format. + The args. + + + + Configuration extension methods for SQL Server. + + + + + Creates an upgrader for SQL Server databases. + + Fluent helper type. + The connection string. + + A builder for a database upgrader designed for SQL Server databases. + + + + + Creates an upgrader for SQL Server databases. + + Fluent helper type. + The connection string. + The SQL schema name to use. Defaults to 'dbo'. + + A builder for a database upgrader designed for SQL Server databases. + + + + + Creates an upgrader for SQL Server databases. + + Fluent helper type. + The connection factory. + + A builder for a database upgrader designed for SQL Server databases. + + + + + Creates an upgrader for SQL Server databases. + + Fluent helper type. + The connection factory. + The SQL schema name to use. Defaults to 'dbo'. + + A builder for a database upgrader designed for SQL Server databases. + + + + + + + + + + + + + Tracks the list of executed scripts in a SQL Server table. + + The builder. + The schema. + The table. + + + + + Add extension methods to this type if you plan to add support for additional databases. + + + + + Reads SQL commands from an underlying text stream. + + + + diff --git a/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DbUp.Support.SqlServer.Scripting.Console.csproj.FileListAbsolute.txt b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DbUp.Support.SqlServer.Scripting.Console.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..a68d7e2 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DbUp.Support.SqlServer.Scripting.Console.csproj.FileListAbsolute.txt @@ -0,0 +1,10 @@ +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting.Console\bin\Debug\DbUp.Support.SqlServer.Scripting.Console.exe.config +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting.Console\obj\Debug\DbUp.Support.SqlServer.Scripting.Console.csprojResolveAssemblyReference.cache +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting.Console\bin\Debug\DbUp.Support.SqlServer.Scripting.Console.exe +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting.Console\bin\Debug\DbUp.Support.SqlServer.Scripting.Console.pdb +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting.Console\bin\Debug\DbUp.dll +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting.Console\bin\Debug\DbUp.Support.SqlServer.Scripting.dll +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting.Console\bin\Debug\DbUp.Support.SqlServer.Scripting.pdb +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting.Console\bin\Debug\DbUp.xml +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting.Console\obj\Debug\DbUp.Support.SqlServer.Scripting.Console.exe +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting.Console\obj\Debug\DbUp.Support.SqlServer.Scripting.Console.pdb diff --git a/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DbUp.Support.SqlServer.Scripting.Console.csprojResolveAssemblyReference.cache b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DbUp.Support.SqlServer.Scripting.Console.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..11e158d Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DbUp.Support.SqlServer.Scripting.Console.csprojResolveAssemblyReference.cache differ diff --git a/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DbUp.Support.SqlServer.Scripting.Console.exe b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DbUp.Support.SqlServer.Scripting.Console.exe new file mode 100644 index 0000000..202e6e0 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DbUp.Support.SqlServer.Scripting.Console.exe differ diff --git a/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DbUp.Support.SqlServer.Scripting.Console.pdb b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DbUp.Support.SqlServer.Scripting.Console.pdb new file mode 100644 index 0000000..54fed77 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DbUp.Support.SqlServer.Scripting.Console.pdb differ diff --git a/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..fe12c98 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/DbUp.Support.SqlServer.Scripting.Console/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/DbUp.Support.SqlServer.Scripting.Console/packages.config b/DbUp.Support.SqlServer.Scripting.Console/packages.config new file mode 100644 index 0000000..9126e6d --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting.Console/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/DbUp.Support.SqlServer.Scripting.sln b/DbUp.Support.SqlServer.Scripting.sln new file mode 100644 index 0000000..ce9e281 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting.sln @@ -0,0 +1,35 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbUp.Support.SqlServer.Scripting", "DbUp.Support.SqlServer.Scripting\DbUp.Support.SqlServer.Scripting.csproj", "{A1EC7074-3C1D-4424-BC80-8BF770758774}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbUp.Support.SqlServer.Scripting.Console", "DbUp.Support.SqlServer.Scripting.Console\DbUp.Support.SqlServer.Scripting.Console.csproj", "{80136911-3220-460B-867D-E1C94E241248}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{36C31DC9-4037-4B0B-B205-F9B9655C9232}" + ProjectSection(SolutionItems) = preProject + build\dbup-sqlserver-scripting.nuspec = build\dbup-sqlserver-scripting.nuspec + build\tools\dbup-sqlserver-scripting.psm1 = build\tools\dbup-sqlserver-scripting.psm1 + Rakefile = Rakefile + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A1EC7074-3C1D-4424-BC80-8BF770758774}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A1EC7074-3C1D-4424-BC80-8BF770758774}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A1EC7074-3C1D-4424-BC80-8BF770758774}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A1EC7074-3C1D-4424-BC80-8BF770758774}.Release|Any CPU.Build.0 = Release|Any CPU + {80136911-3220-460B-867D-E1C94E241248}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {80136911-3220-460B-867D-E1C94E241248}.Debug|Any CPU.Build.0 = Debug|Any CPU + {80136911-3220-460B-867D-E1C94E241248}.Release|Any CPU.ActiveCfg = Release|Any CPU + {80136911-3220-460B-867D-E1C94E241248}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/DbUp.Support.SqlServer.Scripting.suo b/DbUp.Support.SqlServer.Scripting.suo new file mode 100644 index 0000000..28ff986 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting.suo differ diff --git a/DbUp.Support.SqlServer.Scripting.v12.suo b/DbUp.Support.SqlServer.Scripting.v12.suo new file mode 100644 index 0000000..60874fd Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting.v12.suo differ diff --git a/DbUp.Support.SqlServer.Scripting/DbObjectScripter.cs b/DbUp.Support.SqlServer.Scripting/DbObjectScripter.cs new file mode 100644 index 0000000..65dbde2 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/DbObjectScripter.cs @@ -0,0 +1,453 @@ +using DbUp.Engine; +using DbUp.Engine.Output; +using Microsoft.SqlServer.Management.Common; +using Microsoft.SqlServer.Management.Smo; +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Configuration; +using System.Data.SqlClient; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace DbUp.Support.SqlServer.Scripting +{ + public class DbObjectScripter + { + private readonly string m_scrptingObjectRegEx = @"(CREATE|ALTER|DROP)\s*(TABLE|VIEW|PROCEDURE|FUNCTION|SYNONYM) ([\w\[\]\-]+)?\.?([\w\[\]\-]*)"; + private Options m_options; + private string m_definitionDirectory; + private SqlConnectionStringBuilder m_connectionBuilder; + private IUpgradeLog m_log; + + public DbObjectScripter(string connectionString, Options options, IUpgradeLog log) + { + m_connectionBuilder = new SqlConnectionStringBuilder(connectionString); + m_options = options; + m_log = log; + + if (string.IsNullOrEmpty(m_connectionBuilder.InitialCatalog)) + { + throw new InvalidArgumentException("connectionString must include 'Initial Catalog' or 'DATABASE' value!"); + } + + var exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + m_definitionDirectory = Path.GetFullPath(Path.Combine(exePath, m_options.BaseFolderNameDefinitions)).Normalize(); + EnsureDirectoryExists(m_definitionDirectory); + } + + public ScripterResult ScriptAll() + { + ScripterResult result = new ScripterResult(); + + try + { + //When scripting all object, do scripting in parallel so it will go faster. + //We need a DbServerContext for each scripting task since SMO is not thread safe. + + var tablesScriptTask = Task.Run(() => + { + var context = GetDatabaseContext(true); + ScriptAllTables(context); + }); + + var viewsScriptTask = Task.Run(() => + { + var context = GetDatabaseContext(true); + ScriptAllViews(context); + }); + + var storedProceduresScriptTask = Task.Run(() => + { + var context = GetDatabaseContext(true); + ScriptAllStoredProcedures(context); + }); + + var functionsScriptTask = Task.Run(() => + { + var context = GetDatabaseContext(true); + ScriptAllFunctions(context); + }); + + var synonymsScriptTask = Task.Run(() => + { + var context = GetDatabaseContext(true); + ScriptAllSynonyms(context); + }); + + Task.WaitAll( + tablesScriptTask, + viewsScriptTask, + storedProceduresScriptTask, + functionsScriptTask + ); + } + catch (Exception ex) + { + result.Successful = false; + result.Error = ex; + } + + return result; + } + + public ScripterResult ScriptMigrationTargets(IEnumerable migrationScripts) + { + Regex targetDbObjectRegex = new Regex(m_scrptingObjectRegEx, + RegexOptions.IgnoreCase | RegexOptions.Multiline); + + List scriptObjects = new List(); + foreach (SqlScript script in migrationScripts) + { + //extract db object target(s) from scripts + MatchCollection matches = targetDbObjectRegex.Matches(script.Contents); + foreach (Match m in matches) + { + string objectType = m.Groups[2].Value; + + ObjectTypeEnum type; + if (Enum.TryParse(objectType, true, out type)) + { + ObjectActionEnum action = (ObjectActionEnum)Enum.Parse(typeof(ObjectActionEnum), m.Groups[1].Value, true); + var scriptObject = new ScriptObject(type, action); + + if (string.IsNullOrEmpty(m.Groups[4].Value) && !string.IsNullOrEmpty(m.Groups[3].Value)) + { + //no schema specified + scriptObject.ObjectName = m.Groups[3].Value; + } + else + { + scriptObject.ObjectSchema = m.Groups[3].Value; + scriptObject.ObjectName = m.Groups[4].Value; + } + + char[] removeCharacters = new char[] { '[', ']' }; + scriptObject.ObjectSchema = removeCharacters.Aggregate(scriptObject.ObjectSchema, (c1, c2) => c1.Replace(c2.ToString(), "")); + scriptObject.ObjectName = removeCharacters.Aggregate(scriptObject.ObjectName, (c1, c2) => c1.Replace(c2.ToString(), "")); + + scriptObjects.Add(scriptObject); + } + } + } + + return ScriptObjects(scriptObjects); + } + + public ScripterResult ScriptObjects(IEnumerable objects) + { + ScripterResult result = new ScripterResult(); + + try + { + var context = GetDatabaseContext(false); + + ScriptTables(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Table)); + ScriptViews(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.View)); + ScriptStoredProcedures(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Procedure)); + ScriptFunctions(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Function)); + ScriptSynonyms(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Synonym)); + } + catch (Exception ex) + { + result.Successful = false; + result.Error = ex; + } + + return result; + } + + protected void ScriptAllTables(DbServerContext context) + { + if ((m_options.ObjectsToInclude & ObjectTypeEnum.Table) == ObjectTypeEnum.Table) + { + List tables = new List(); + foreach (Table table in context.Database.Tables) + { + if (!table.IsSystemObject) + { + tables.Add(new ScriptObject(ObjectTypeEnum.Table, ObjectActionEnum.Create) + { + ObjectName = table.Name, + ObjectSchema = table.Schema + }); + } + } + + ScriptTables(context, tables); + } + } + + protected void ScriptTables(DbServerContext context, IEnumerable tables) + { + if ((m_options.ObjectsToInclude & ObjectTypeEnum.Table) == ObjectTypeEnum.Table) + { + string outputDirectory = Path.Combine(m_definitionDirectory, m_options.FolderNameTables); + + foreach (ScriptObject tableObject in tables) + { + if (tableObject.ObjectAction == ObjectActionEnum.Drop) + { + DeleteScript(tableObject, outputDirectory); + } + else + { + Table currentTable = context.Database.Tables[tableObject.ObjectName, tableObject.ObjectSchema]; + + ScriptDefinition(tableObject, outputDirectory, new Func(() => + { + return currentTable.Script(m_options.ScriptingOptions); + })); + } + } + } + } + + protected void ScriptAllViews(DbServerContext context) + { + if ((m_options.ObjectsToInclude & ObjectTypeEnum.View) == ObjectTypeEnum.View) + { + List views = new List(); + foreach (View view in context.Database.Views) + { + if (!view.IsSystemObject) + { + views.Add(new ScriptObject(ObjectTypeEnum.View, ObjectActionEnum.Create) + { + ObjectName = view.Name, + ObjectSchema = view.Schema + }); + } + } + + ScriptViews(context, views); + } + } + + protected void ScriptViews(DbServerContext context, IEnumerable views) + { + if ((m_options.ObjectsToInclude & ObjectTypeEnum.View) == ObjectTypeEnum.View) + { + string outputDirectory = Path.Combine(m_definitionDirectory, m_options.FolderNameViews); + + foreach (ScriptObject viewObject in views) + { + if (viewObject.ObjectAction == ObjectActionEnum.Drop) + { + DeleteScript(viewObject, outputDirectory); + } + else + { + View currentView = context.Database.Views[viewObject.ObjectName, viewObject.ObjectSchema]; + ScriptDefinition(viewObject, outputDirectory, new Func(() => + { + return currentView.Script(m_options.ScriptingOptions); + })); + } + } + } + } + + protected void ScriptAllStoredProcedures(DbServerContext context) + { + if ((m_options.ObjectsToInclude & ObjectTypeEnum.Procedure) == ObjectTypeEnum.Procedure) + { + List sprocs = new List(); + foreach (StoredProcedure sproc in context.Database.StoredProcedures) + { + if (!sproc.IsSystemObject) + { + sprocs.Add(new ScriptObject(ObjectTypeEnum.Procedure, ObjectActionEnum.Create) + { + ObjectName = sproc.Name, + ObjectSchema = sproc.Schema + }); + } + } + + ScriptStoredProcedures(context, sprocs); + } + } + + protected void ScriptStoredProcedures(DbServerContext context, IEnumerable sprocs) + { + if ((m_options.ObjectsToInclude & ObjectTypeEnum.Procedure) == ObjectTypeEnum.Procedure) + { + string outputDirectory = Path.Combine(m_definitionDirectory, m_options.FolderNameProcedures); + + foreach (ScriptObject sprocObject in sprocs) + { + if (sprocObject.ObjectAction == ObjectActionEnum.Drop) + { + DeleteScript(sprocObject, outputDirectory); + } + else + { + StoredProcedure currentSproc = context.Database.StoredProcedures[sprocObject.ObjectName, sprocObject.ObjectSchema]; + ScriptDefinition(sprocObject, outputDirectory, new Func(() => + { + return currentSproc.Script(m_options.ScriptingOptions); + })); + } + } + } + } + + protected void ScriptAllFunctions(DbServerContext context) + { + if ((m_options.ObjectsToInclude & ObjectTypeEnum.Function) == ObjectTypeEnum.Function) + { + List tables = new List(); + foreach (UserDefinedFunction udf in context.Database.UserDefinedFunctions) + { + if (!udf.IsSystemObject) + { + tables.Add(new ScriptObject(ObjectTypeEnum.Function, ObjectActionEnum.Create) + { + ObjectName = udf.Name, + ObjectSchema = udf.Schema + }); + } + } + + ScriptFunctions(context, tables); + } + } + + protected void ScriptFunctions(DbServerContext context, IEnumerable udfs) + { + if ((m_options.ObjectsToInclude & ObjectTypeEnum.Function) == ObjectTypeEnum.Function) + { + string outputDirectory = Path.Combine(m_definitionDirectory, m_options.FolderNameFunctions); + + foreach (ScriptObject udfObject in udfs) + { + if (udfObject.ObjectAction == ObjectActionEnum.Drop) + { + DeleteScript(udfObject, outputDirectory); + } + else + { + UserDefinedFunction currentUdf = context.Database.UserDefinedFunctions[udfObject.ObjectName, udfObject.ObjectSchema]; + ScriptDefinition(udfObject, outputDirectory, new Func(() => + { + return currentUdf.Script(m_options.ScriptingOptions); + })); + } + } + } + } + + protected void ScriptAllSynonyms(DbServerContext context) + { + if ((m_options.ObjectsToInclude & ObjectTypeEnum.Synonym) == ObjectTypeEnum.Synonym) + { + List synonyms = new List(); + foreach (Synonym synonym in context.Database.Synonyms) + { + synonyms.Add(new ScriptObject(ObjectTypeEnum.Synonym, ObjectActionEnum.Create) + { + ObjectName = synonym.Name, + ObjectSchema = synonym.Schema + }); + } + + ScriptSynonyms(context, synonyms); + } + } + + protected void ScriptSynonyms(DbServerContext context, IEnumerable synonyms) + { + if ((m_options.ObjectsToInclude & ObjectTypeEnum.Synonym) == ObjectTypeEnum.Synonym) + { + string outputDirectory = Path.Combine(m_definitionDirectory, m_options.FolderNameSynonyms); + + foreach (ScriptObject synonymObject in synonyms) + { + Synonym curentSynonym = context.Database.Synonyms[synonymObject.ObjectName, synonymObject.ObjectSchema]; + ScriptDefinition(synonymObject, outputDirectory, new Func(() => + { + return curentSynonym.Script(m_options.ScriptingOptions); + })); + } + } + } + + private DbServerContext GetDatabaseContext(bool loadAllFields = false) + { + DbServerContext context = new DbServerContext(); + SqlConnection connection = new SqlConnection(m_connectionBuilder.ConnectionString); + ServerConnection serverConnection = new ServerConnection(connection); + context.Server = new Server(serverConnection); + context.Database = context.Server.Databases[m_connectionBuilder.InitialCatalog]; + + context.Server.SetDefaultInitFields(loadAllFields); + + return context; + } + + private void ScriptDefinition(ScriptObject dbObject, string outputDirectory, Func scripter) + { + try + { + StringCollection script = scripter(); + SaveScript(dbObject, script, outputDirectory); + } + catch (Exception ex) + { + m_log.WriteError(string.Format("Error when scripting definition for {0}: {1}", dbObject.ObjectName, ex.Message)); + } + } + + private void SaveScript(ScriptObject scriptObject, StringCollection script, string outputDirectory) + { + try + { + EnsureDirectoryExists(outputDirectory); + + StringBuilder sb = new StringBuilder(); + foreach (string str in script) + { + sb.Append(str); + sb.Append(Environment.NewLine); + } + + m_log.WriteInformation(string.Format("Saving definition for: {0}", scriptObject.FullName)); + File.WriteAllText(Path.Combine(outputDirectory, scriptObject.FileName), sb.ToString()); + } + catch (Exception ex) + { + m_log.WriteError(string.Format("Error when saving script file {0}: {1}", scriptObject.FullName, ex.Message)); + } + } + + private void DeleteScript(ScriptObject scriptObject, string outputDirectory) + { + try + { + string filePath = Path.Combine(outputDirectory, scriptObject.FileName); + if (File.Exists(filePath)) + { + m_log.WriteInformation(string.Format("Deleting definition for: {0}", scriptObject.FullName)); + File.Delete(filePath); + } + } + catch (Exception ex) + { + m_log.WriteError(string.Format("Error when deleting script file {0}: {1}", scriptObject.FullName, ex.Message)); + } + } + + private void EnsureDirectoryExists(string directoryPath) + { + if (!Directory.Exists(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + } + } +} diff --git a/DbUp.Support.SqlServer.Scripting/DbUp.Support.SqlServer.Scripting.csproj b/DbUp.Support.SqlServer.Scripting/DbUp.Support.SqlServer.Scripting.csproj new file mode 100644 index 0000000..4513885 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/DbUp.Support.SqlServer.Scripting.csproj @@ -0,0 +1,98 @@ + + + + + Debug + AnyCPU + {A1EC7074-3C1D-4424-BC80-8BF770758774} + Library + Properties + DbUp.Support.SqlServer.Scripting + DbUp.Support.SqlServer.Scripting + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\packages\dbup.3.2.1\lib\NET35\DbUp.dll + + + True + ..\packages\Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8\lib\Microsoft.SqlServer.ConnectionInfo.dll + + + True + ..\packages\Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8\lib\Microsoft.SqlServer.ConnectionInfoExtended.dll + + + True + ..\packages\Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8\lib\Microsoft.SqlServer.Management.Sdk.Sfc.dll + + + True + ..\packages\Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8\lib\Microsoft.SqlServer.Smo.dll + + + True + ..\packages\Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8\lib\Microsoft.SqlServer.SmoExtended.dll + + + True + ..\packages\Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8\lib\Microsoft.SqlServer.SqlClrProvider.dll + + + True + ..\packages\Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8\lib\Microsoft.SqlServer.SqlEnum.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DbUp.Support.SqlServer.Scripting/ObjectActionEnum.cs b/DbUp.Support.SqlServer.Scripting/ObjectActionEnum.cs new file mode 100644 index 0000000..c8619d6 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/ObjectActionEnum.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DbUp.Support.SqlServer.Scripting +{ + public enum ObjectActionEnum + { + Create, + Alter, + Drop + } +} diff --git a/DbUp.Support.SqlServer.Scripting/ObjectTypeEnum.cs b/DbUp.Support.SqlServer.Scripting/ObjectTypeEnum.cs new file mode 100644 index 0000000..17cac9c --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/ObjectTypeEnum.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DbUp.Support.SqlServer.Scripting +{ + [Flags] + public enum ObjectTypeEnum : int + { + Table = 1, + View = 2, + Procedure = 4, + Function = 8, + Synonym = 16 + } +} diff --git a/DbUp.Support.SqlServer.Scripting/Options.cs b/DbUp.Support.SqlServer.Scripting/Options.cs new file mode 100644 index 0000000..8e55729 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/Options.cs @@ -0,0 +1,45 @@ +using Microsoft.SqlServer.Management.Smo; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DbUp.Support.SqlServer.Scripting +{ + public class Options + { + public Options() + { + this.BaseFolderNameDefinitions = "Definitions"; + this.FolderNameTables = "Tables"; + this.FolderNameViews = "Views"; + this.FolderNameProcedures = "Procedures"; + this.FolderNameFunctions = "Functions"; + this.FolderNameSynonyms = "Synonyms"; + + this.ObjectsToInclude = ObjectTypeEnum.Function + | ObjectTypeEnum.Procedure + | ObjectTypeEnum.Synonym + | ObjectTypeEnum.Table + | ObjectTypeEnum.View; + + this.ScriptingOptions = new ScriptingOptions() + { + Default = true, + ClusteredIndexes = true, + NonClusteredIndexes = true, + DriAll = true + }; + } + + public ScriptingOptions ScriptingOptions { get; set; } + public string BaseFolderNameDefinitions { get; set; } + public string FolderNameTables { get; set; } + public string FolderNameViews { get; set; } + public string FolderNameProcedures { get; set; } + public string FolderNameFunctions { get; set; } + public string FolderNameSynonyms { get; set; } + public ObjectTypeEnum ObjectsToInclude { get; set; } + } +} diff --git a/DbUp.Support.SqlServer.Scripting/Properties/AssemblyInfo.cs b/DbUp.Support.SqlServer.Scripting/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..bb1b00f --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("DbProphet")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("DbProphet")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("78af15c8-c2b5-410d-8984-cf2ec4bfdef8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DbUp.Support.SqlServer.Scripting/ScriptObject.cs b/DbUp.Support.SqlServer.Scripting/ScriptObject.cs new file mode 100644 index 0000000..3de488f --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/ScriptObject.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DbUp.Support.SqlServer.Scripting +{ + public class ScriptObject + { + public ScriptObject(ObjectTypeEnum type, ObjectActionEnum action) + { + this.ObjectSchema = "dbo"; + this.ObjectType = type; + this.ObjectAction = action; + } + + public ObjectTypeEnum ObjectType { get; set; } + public ObjectActionEnum ObjectAction { get; set; } + public string ObjectSchema { get; set; } + public string ObjectName { get; set; } + + public string FullName + { + get + { + string name = this.ObjectSchema; + if (!string.IsNullOrEmpty(name)) + { + name += "."; + } + name += this.ObjectName; + + return name; + } + } + + public string FileName + { + get { return this.FullName + ".sql"; } + } + } +} diff --git a/DbUp.Support.SqlServer.Scripting/ScripterResult.cs b/DbUp.Support.SqlServer.Scripting/ScripterResult.cs new file mode 100644 index 0000000..8971f5f --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/ScripterResult.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DbUp.Support.SqlServer.Scripting +{ + public class ScripterResult + { + public ScripterResult() + { + this.Successful = true; + } + + public Exception Error { get; set; } + public bool Successful { get; set; } + } +} diff --git a/DbUp.Support.SqlServer.Scripting/ScriptingUpgrader.cs b/DbUp.Support.SqlServer.Scripting/ScriptingUpgrader.cs new file mode 100644 index 0000000..888ba44 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/ScriptingUpgrader.cs @@ -0,0 +1,133 @@ +using DbUp; +using DbUp.Builder; +using DbUp.Engine; +using DbUp.Engine.Output; +using DbUp.Support.SqlServer; +using DbUp.Support.SqlServer.Scripting; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace DbUp +{ + public class ScriptingUpgrader + { + UpgradeEngine m_engine; + Options m_options; + + public ScriptingUpgrader(UpgradeEngine engine, Options options) + { + m_engine = engine; + m_options = options; + } + + public ScriptingUpgrader(UpgradeEngine engine) + : this(engine, new Options()) + { + } + + UpgradeConfiguration m_configuration; + UpgradeConfiguration UpgradeConfiguration + { + get + { + if (m_configuration == null) + { + var field = typeof(UpgradeEngine).GetField("configuration", BindingFlags.NonPublic | BindingFlags.Instance); + m_configuration = (UpgradeConfiguration)field.GetValue(m_engine); + } + + return m_configuration; + } + } + + IUpgradeLog m_log; + IUpgradeLog Log + { + get + { + if (m_log == null) + { + m_log = this.UpgradeConfiguration.Log; + } + + return m_log; + } + } + + string m_connectionString; + string ConnectionString + { + get + { + if (m_connectionString == null) + { + var connectionManager = this.UpgradeConfiguration.ConnectionManager; + if (connectionManager is SqlConnectionManager) + { + var field = typeof(SqlConnectionManager).GetField("connectionString", BindingFlags.NonPublic | BindingFlags.Instance); + m_connectionString = (string)field.GetValue((SqlConnectionManager)connectionManager); + } + } + + return m_connectionString; + } + } + + public DatabaseUpgradeResult ScriptAll() + { + this.Log.WriteInformation("Scripting all database object definitions..."); + + if (this.ConnectionString == null) + { + return new DatabaseUpgradeResult(null, false, new Exception("connectionString could not be determined")); + } + + var scripter = new DbObjectScripter(this.ConnectionString, m_options, this.Log); + scripter.ScriptAll(); + + return new DatabaseUpgradeResult(null, true, null); + } + + public DatabaseUpgradeResult PerformUpgrade(string[] args) + { + DatabaseUpgradeResult result = null; + if (args.Any(a => "--scriptAllDefinitions".Equals(a, StringComparison.InvariantCultureIgnoreCase))) + { + result = ScriptAll(); + } + else + { + var scriptsToExecute = m_engine.GetScriptsToExecute(); + + if (args.Any(a => "--whatIf".Equals(a, StringComparison.InvariantCultureIgnoreCase))) + { + result = new DatabaseUpgradeResult(null, true, null); + + this.Log.WriteWarning("WHATIF Mode!"); + this.Log.WriteWarning("The following scripts would have been executed:"); + scriptsToExecute.ForEach(r => this.Log.WriteWarning(r.Name)); + } + else + { + result = m_engine.PerformUpgrade(); + + if (result.Successful + && args.Any(a => "--fromconsole".Equals(a, StringComparison.InvariantCultureIgnoreCase))) + { + this.Log.WriteInformation("Scripting changed database objects..."); + var scripter = new DbObjectScripter(this.ConnectionString, m_options, this.Log); + var scriptorResult = scripter.ScriptMigrationTargets(scriptsToExecute); + } + } + } + + return result; + } + } +} diff --git a/DbUp.Support.SqlServer.Scripting/ServerContext.cs b/DbUp.Support.SqlServer.Scripting/ServerContext.cs new file mode 100644 index 0000000..fa5a7d7 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/ServerContext.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DbUp.Support.SqlServer.Scripting +{ + public class DbServerContext + { + public Microsoft.SqlServer.Management.Smo.Server Server { get; set; } + public Microsoft.SqlServer.Management.Smo.Database Database { get; set; } + } +} diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/DbProphet.dll b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbProphet.dll new file mode 100644 index 0000000..a7bf5dc Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbProphet.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/DbProphet.pdb b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbProphet.pdb new file mode 100644 index 0000000..36bfb78 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbProphet.pdb differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/DbSeer.dll b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbSeer.dll new file mode 100644 index 0000000..4d77f65 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbSeer.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/DbSeer.pdb b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbSeer.pdb new file mode 100644 index 0000000..3a1d7a4 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbSeer.pdb differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.Scripting.dll b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.Scripting.dll new file mode 100644 index 0000000..8e0bf03 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.Scripting.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.Scripting.pdb b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.Scripting.pdb new file mode 100644 index 0000000..6ad6252 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.Scripting.pdb differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.Support.SqlServer.Scripting.dll b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.Support.SqlServer.Scripting.dll new file mode 100644 index 0000000..e231e1c Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.Support.SqlServer.Scripting.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.Support.SqlServer.Scripting.pdb b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.Support.SqlServer.Scripting.pdb new file mode 100644 index 0000000..798891d Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.Support.SqlServer.Scripting.pdb differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.dll b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.dll new file mode 100644 index 0000000..ccf14aa Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.xml b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.xml new file mode 100644 index 0000000..e1d4579 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/bin/Debug/DbUp.xml @@ -0,0 +1,1334 @@ + + + + DbUp + + + + + Configuration extensions for the standard stuff. + + + + + Logs to a custom logger. + + + The logger. + + The same builder + + + + + Logs to the console using pretty colours. + + The builder. + + The same builder + + + + + Logs to the console using pretty colours. + + The builder. + + The same builder + + + + + Logs to System.Diagnostics.Trace. + + The builder. + + The same builder + + + + + Uses a custom journal for recording which scripts were executed. + + The builder. + The custom journal. + + The same builder + + + + + Adds a custom script provider to the upgrader. + + The builder. + The script provider. + + The same builder + + + + + Adds a static set of scripts to the upgrader. + + The builder. + The scripts. + + The same builder + + + + + Adds a static set of scripts to the upgrader. + + The builder. + The scripts. + + The same builder + + + + + Adds a single static script to the upgrader. + + The builder. + The script. + + The same builder + + + + + Adds a single static script to the upgrader. + + The builder. + The name of the script. This should never change once executed. + The script body. + + The same builder + + + + + Adds all scripts from a folder on the file system. + + The builder. + The directory path. + + The same builder + + + + + Adds all scripts from a folder on the file system, with a custom filter. + + The builder. + The directory path. + The filter. Use the static class to get some pre-defined filters. + + The same builder + + + + + Adds all scripts found as embedded resources in the given assembly. + + The builder. + The assembly. + + The same builder + + + + + Adds all scripts found as embedded resources in the given assembly, with a custom filter (you'll need to exclude non- .SQL files yourself). + + The builder. + The assembly. + The filter. Don't forget to ignore any non- .SQL files. + + The same builder + + + + + Adds all scripts found as embedded resources in the given assembly, or classes which inherit from IScript, with a custom filter (you'll need to exclude non- .SQL files yourself). + + The builder. + The assembly. + + The same builder + + + + + Adds all scripts found as embedded resources in the given assembly, or classes which inherit from IScript, with a custom filter (you'll need to exclude non- .SQL files yourself). + + The builder. + The assembly. + The Sql Script filter (only affects embdeeded scripts, does not filter IScript files). Don't forget to ignore any non- .SQL files. + + The same builder + + + + + Adds a preprocessor that can replace portions of a script. + + The builder. + The preprocessor. + + The same builder + + + + + Adds a set of variables that will be replaced before scripts are executed. + + The builder. + The variables. + + The same builder + + + + + Adds a single variable that will be replaced before scripts are executed. + + The builder. + The name of the variable. + The value to be substituted. + + + + + Sets a configuration flag which will cause the engine to skip variable expansion. + + The builder. + + + + + Sets a configuration flag which will cause the engine to perform variable expansion. + + The builder. + + + + + Allows you to set the execution timeout for scripts. + + The builder. + A TimeSpan value containing the timeout value or null. + The timeout value is less than zero or greater than 2,147,483,647 seconds. + Setting the timeout parameter to null will use the default timeout of the underlying provider. + + + + + Run creates a new connection for each script, without a transaction + + + + + + + Run DbUp in a single transaction + + + + + + + Run each script in it's own transaction + + + + + + + Represents the configuration of an UpgradeEngine. + + + + + Initializes a new instance of the class. + + + + + Ensures all expectations have been met regarding this configuration. + + + + + Adds variables to the configuration which will be substituted for every script + + The variables + + + + Manages your database connections, allowing you to control the use of transactions and the behaviour of those transactions + + + + + Gets or sets a log which captures details about the upgrade. + + + + + Gets a mutable list of script providers. + + + + + Gets a mutable list of script pre-processors. + + + + + Gets or sets the journal, which tracks the scripts that have already been run. + + + + + Gets or sets the script executor, which runs scripts against the underlying database. + + + + + A collection of variables to be replaced in scripts before they are run + + + + + Determines if variables should be replaced in scripts before they are run. + + + + + Builds a UpgradeEngine by accepting a list of callbacks to execute. For custom configuration, you should + implement extension methods on top of this class. + + + + + Adds a callback that will be run to configure the upgrader when Build is called. + + The configuration. + + + + Creates an UpgradeEngine based on this configuration. + + + + + + A fluent builder for creating database upgraders. + + + + + Returns the databases supported by DbUp. + + + + + Manages Sql Database Connections + + + + + Allows you to run an operation with a managed connection + + + + + Tells the connection manager it is starting an operation + + + + + Execute a lambda with the connection managed by the connection manager (i.e transactions, reusing connections etc) + + Action to execute + + + + Execute a lambda with the connection managed by the connection manager (i.e transactions, reusing connections etc) + + Action to execute + + + + Scripts often have multiple statements which have to be executed in their own commands. + + For example, MSSQL splits on GO, SQLite splits on ; etc. + + + + + Specifies the transaction strategy + + + + + Specifies whether the db script output should be logged + + + + + Manages Database Connections + + + + + Creates a database connection for the current database engine + + + + + Tells the connection manager is starting + + + + + Executes an action using the specfied transaction mode + + The action to execute + + + + Executes an action which has a result using the specfied transaction mode + + The action to execute + The result type + The result of the command + + + + Splits a script into commands, for example SQL Server separates command by the GO statement + + The script + A list of SQL Commands + + + + The transaction strategy that DbUp should use + + + + + Specifies whether the db script output should be logged + + + + + A class which represents a script, allowing you to dynamically generate a sql script at runtime + + + + + Provides the Sql Script to execute + + A factory to create open and active database commands + The Sql Script contents + + + + The transaction strategy being to be used by the DatabaseConnectionManager + + + + + Executes an action + + + + + + Executes an action which has a result + + + + + + + + Initialises the transaction strategy with the upgrade log + + + + + Represents a SQL Server script that is fetched at execution time, rather than discovery time + + + + + Represents a SQL Server script that comes from an embedded resource in an assembly. + + + + + Initializes a new instance of the class. + + The name. + The contents. + + + + + + + + + + + + + + + + + + + Gets the contents of the script. + + + + + + Gets the name of the script. + + + + + + Initializes a new instance of the class. + + The name. + The delegate which creates the content at execution time. + + + + Gets the contents of the script. + + + + + + Used for database engines that do not support schema's, it will remove $schema$. from all scripts + + + + + Preprocessor that executes before scripts are executed against the database + + + + + Performs some proprocessing step on a script + + + + + Performs some proprocessing step on a script + + + + + The transaction strategy to use + + + + + Run creates a new connection for each script, without a transaction + + + + + DbUp will run using a single transaction for the whole upgrade operation + + + + + DbUp will create a new connection and transaction per script + + + + + A factory class for filter methods. + + + + + This filter will exclude scripts that are listed in a file. + + + The file should contain a single script name per line. + + The file that contains the script names to be excluded, one per line. + + + + + This filter will only include scripts that are listed in a file. All other scripts will be excluded. + + + The file should contain a single script name per line. + + The file that contains the script names to be included, one per line. + + + + + This filter will exclude the specified scripts. + + The names of the scripts to be excluded. + + + + + This filter will include only the specified scripts, and exclude any others. + + The names of the scripts to be included. + + + + + Enables multiple executions of idempotent scripts. + + + + + This interface is provided to allow different projects to store version information differently. + + + + + Recalls the version number of the database. + + + + + + Records an upgrade script for a database. + + The script. + + + + Returns an empty array of length 0 + + + + + + Does not store the script, simply returns + + + + + + An implementation of the interface which tracks version numbers for a + Firebird database using a table called SchemaVersions. + + + + + Creates a new Firebird table journal. + + The Firebird connection manager. + The upgrade logger. + The name of the journal table. + + + + Fetches the list of already executed scripts. + + + + + + Records an upgrade script for a database. + + The script. + + + + An implementation of the interface which tracks version numbers for a + PostgreSQL database using a table called SchemaVersions. + + + + + Creates a new MySql table journal. + + The MySql connection manager. + The upgrade logger. + The name of the schema the journal is stored in. + The name of the journal table. + + + + Records an upgrade script for a database. + + The script. + + + + An implementation of the interface which tracks version numbers for a + PostgreSQL database using a table called SchemaVersions. + + + + + Creates a new PostgreSQL table journal. + + The PostgreSQL connection manager. + The upgrade logger. + The name of the schema the journal is stored in. + The name of the journal table. + + + + Records an upgrade script for a database. + + The script. + + + + Responsible for splitting SQL text into a list of commands. + + + + + Returns the seperate executable SQL commands within the SQL script. + + + + + + + Manages Sql Database Connections + + + + + Manages Sql Database Connections + + + + + + A helper for executing SQL queries easily. + + + + + Initializes a new instance of the class. + + The command factory. + The schema. + The additional script preprocessors. + Sets the variablesEnabled setting to true. + + + + Initializes a new instance of the class. + + The command factory. + The schema. + Function indicating true if variables should be replaced, false otherwise. + The additional script preprocessors. + + + + Adds a variable to be substituted on Adhoc script + + + + + + + + Executes a scalar query. + + The query. + The parameters. + + + + + Executes a query that returns the number of records modified. + + The query. + The parameters. + + + + + Executes a select query or procedure. + + The query. + The parameters. + + + + + Database Schema, should be null if database does not support schemas + + + + + A log that writes to the console in a colorful way. + + + + + Implemented by objects which record the internal details of the database migration. + + + + + Writes an informational message to the log. + + The format. + The args. + + + + Writes an error message to the log. + + The format. + The args. + + + + Writes a warning message to the log. + + The format. + The args. + + + + Writes an informational message to the log. + + The format. + The args. + + + + Writes an error message to the log. + + The format. + The args. + + + + Writes a warning message to the log. + + The format. + The args. + + + + This class orchestrates the database upgrade process. + + + + + Initializes a new instance of the class. + + The configuration. + + + + Determines whether the database is out of date and can be upgraded. + + + + + Tries to connect to the database. + + Any error message encountered. + + + + + Performs the database upgrade. + + + + + Returns a list of scripts that will be executed when the upgrade is performed + + The scripts to be executed + + + + Creates version record for any new migration scripts without executing them. + Useful for bringing development environments into sync with automated environments + + + + + + Represents the results of a database upgrade. + + + + + Initializes a new instance of the class. + + The scripts that were executed. + if set to true [successful]. + The error. + + + + Gets the scripts that were executed. + + + + + Gets a value indicating whether this is successful. + + + + + Gets the error. + + + + + This interface is implemented by classes that execute upgrade scripts against a database. + + + + + Executes the specified script against a database at a given connection string. + + The script. + + + + Executes the specified script against a database at a given connection string. + + The script. + Variables to replace in the script + + + + Verifies the specified schema exists and is valid + + + + + Timeout for each section of the script in seconds. If not set, the default timeout for the executor is used. + + + + + An enhanced implementation which retrieves upgrade scripts or IScript code upgrade scripts embedded in an assembly. + + + + + Provides scripts to be executed. + + + + + Gets all scripts that should be executed. + + + + + Initializes a new instance of the class. + + The assembly. + The embedded sql script filter. + + + + Gets all scripts that should be executed. + + + + + Allows backwards compatibility with previous API/behaviour of using connection factories with DbUp + + + + + Ctor for LegacySqlConnectionManager + + The connectionFactory + + + + No options are set. + + + + + Remove starting and ending white space from the object name. + + + + + Quotes the name of the SQLite object in square brackets to allow Special characters in the object name. + + Name of the object to quote. + The quoted object name with trimmed whitespace + + + + Quotes the name of the SQLite object in square brackets to allow Special characters in the object name. + + Name of the object to quote. + The settings which indicate if the whitespace should be dropped or not. + The quoted object name + + + + An implementation of the interface which tracks version numbers for a + SQLite database using a table called SchemaVersions. + + + + + An implementation of the interface which tracks version numbers for a + SQL Server database using a table called dbo.SchemaVersions. + + + + + Initializes a new instance of the class. + + The connection manager. + The log. + The schema that contains the table. + The table name. + + var journal = new TableJournal("Server=server;Database=database;Trusted_Connection=True", "dbo", "MyVersionTable"); + + + + + Recalls the version number of the database. + + All executed scripts. + + + + The Sql which gets + + + + + Records a database upgrade for a database specified in a given connection string. + + The script. + + + + The sql to exectute to create the schema versions table + + + + + + + Initializes a new instance of the class. + + + + + Create table sql for SQLite + + + + + + + Parses Sql Objects and performs quoting functions + + + + + Quotes the name of the SQL object in square brackets to allow Special characters in the object name. + This function implements System.Data.SqlClient.SqlCommandBuilder.QuoteIdentifier() with an additional + validation which is missing from the SqlCommandBuilder version. + + Name of the object to quote. + The quoted object name with trimmed whitespace + + + + Quotes the name of the SQL object in square brackets to allow Special characters in the object name. + This function implements System.Data.SqlClient.SqlCommandBuilder.QuoteIdentifier() with an additional + validation which is missing from the SqlCommandBuilder version. + + Name of the object to quote. + The settings which indicate if the whitespace should be dropped or not. + The quoted object name + + + + A standard implementation of the IScriptExecutor interface that executes against a SQL Server + database. + + + + + Initializes an instance of the class. + + + The logging mechanism. + The schema that contains the table. + Function that returns true if variables should be replaced, false otherwise. + Script Preprocessors in addition to variable substitution + + + + Executes the specified script against a database at a given connection string. + + The script. + + + + Verifies the existence of targeted schema. If schema is not verified, will check for the existence of the dbo schema. + + + + + Executes the specified script against a database at a given connection string. + + The script. + Variables to replace in the script + + + + SQLCommand Timeout in seconds. If not set, the default SQLCommand timeout is not changed. + + + + + Database Schema, should be null if database does not support schemas + + + + + Substitutes variables for values in SqlScripts + + + + + Initializes a new instance of the class. + + The variables. + + + + Substitutes variables + + + + + + Allows you to easily programatically supply scripts from code. + + + + + Initializes a new instance of the class. + + The scripts. + + + + Gets all scripts that should be executed. + + + + + The default implementation which retrieves upgrade scripts embedded in an assembly. + + + + + Initializes a new instance of the class. + + The assembly. + The filter. + + + + Gets all scripts that should be executed. + + + + + + Alternate implementation which retrieves upgrade scripts via a directory + + + + + + Path to SQL upgrade scripts + + + + + Path to SQL upgrade scripts + The filter. + + + + Gets all scripts that should be executed. + + + + + Used to create databases that are deleted at the end of a unit test. + + + + + Creates new TemporarySqlDatabase against (local) + + + + + Initializes a new instance of the class. + + The name. + + + + Creates the database. + + + + + Deletes the database. + + + + + Gets the connection string. + + The connection string. + + + + Gets a tool to run ad-hoc SQL queries. + + The ad hoc. + + + + A log that writes to System.Diagnostics.Trace. + + + + + Writes an informational message to the log. + + The format. + The args. + + + + Writes an error message to the log. + + The format. + The args. + + + + Writes a warning message to the log. + + The format. + The args. + + + + Configuration extension methods for SQL Server. + + + + + Creates an upgrader for SQL Server databases. + + Fluent helper type. + The connection string. + + A builder for a database upgrader designed for SQL Server databases. + + + + + Creates an upgrader for SQL Server databases. + + Fluent helper type. + The connection string. + The SQL schema name to use. Defaults to 'dbo'. + + A builder for a database upgrader designed for SQL Server databases. + + + + + Creates an upgrader for SQL Server databases. + + Fluent helper type. + The connection factory. + + A builder for a database upgrader designed for SQL Server databases. + + + + + Creates an upgrader for SQL Server databases. + + Fluent helper type. + The connection factory. + The SQL schema name to use. Defaults to 'dbo'. + + A builder for a database upgrader designed for SQL Server databases. + + + + + + + + + + + + + Tracks the list of executed scripts in a SQL Server table. + + The builder. + The schema. + The table. + + + + + Add extension methods to this type if you plan to add support for additional databases. + + + + + Reads SQL commands from an underlying text stream. + + + + diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.ConnectionInfo.dll b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.ConnectionInfo.dll new file mode 100644 index 0000000..9ceef99 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.ConnectionInfo.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.ConnectionInfoExtended.dll b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.ConnectionInfoExtended.dll new file mode 100644 index 0000000..3363349 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.ConnectionInfoExtended.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.Management.Sdk.Sfc.dll b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.Management.Sdk.Sfc.dll new file mode 100644 index 0000000..a59befb Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.Management.Sdk.Sfc.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.Smo.dll b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.Smo.dll new file mode 100644 index 0000000..19cf7b2 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.Smo.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.SmoExtended.dll b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.SmoExtended.dll new file mode 100644 index 0000000..9a8f4f3 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.SmoExtended.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.SqlClrProvider.dll b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.SqlClrProvider.dll new file mode 100644 index 0000000..f07af62 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.SqlClrProvider.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.SqlEnum.dll b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.SqlEnum.dll new file mode 100644 index 0000000..54b9c1f Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/bin/Debug/Microsoft.SqlServer.SqlEnum.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbProphet.csproj.FileListAbsolute.txt b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbProphet.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..ff552cc --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbProphet.csproj.FileListAbsolute.txt @@ -0,0 +1,28 @@ +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\DbProphet.dll +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\DbProphet.pdb +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\DbUp.dll +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.ConnectionInfo.dll +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.ConnectionInfoExtended.dll +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.Management.Sdk.Sfc.dll +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.Smo.dll +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.SmoExtended.dll +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.SqlClrProvider.dll +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.SqlEnum.dll +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\DbUp.xml +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\obj\Debug\DbProphet.csprojResolveAssemblyReference.cache +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\obj\Debug\DbProphet.dll +C:\Users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\obj\Debug\DbProphet.pdb +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\bin\Debug\DbProphet.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\bin\Debug\DbProphet.pdb +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\bin\Debug\DbUp.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\bin\Debug\Microsoft.SqlServer.ConnectionInfo.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\bin\Debug\Microsoft.SqlServer.ConnectionInfoExtended.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\bin\Debug\Microsoft.SqlServer.Management.Sdk.Sfc.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\bin\Debug\Microsoft.SqlServer.Smo.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\bin\Debug\Microsoft.SqlServer.SmoExtended.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\bin\Debug\Microsoft.SqlServer.SqlClrProvider.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\bin\Debug\Microsoft.SqlServer.SqlEnum.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\bin\Debug\DbUp.xml +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\obj\Debug\DbProphet.csprojResolveAssemblyReference.cache +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\obj\Debug\DbProphet.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbProphet\DbProphet\obj\Debug\DbProphet.pdb diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbProphet.csprojResolveAssemblyReference.cache b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbProphet.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..aef4e7d Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbProphet.csprojResolveAssemblyReference.cache differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbProphet.dll b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbProphet.dll new file mode 100644 index 0000000..a7bf5dc Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbProphet.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbProphet.pdb b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbProphet.pdb new file mode 100644 index 0000000..36bfb78 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbProphet.pdb differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbSeer.csproj.FileListAbsolute.txt b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbSeer.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..f0b0539 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbSeer.csproj.FileListAbsolute.txt @@ -0,0 +1,14 @@ +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\obj\Debug\DbSeer.csprojResolveAssemblyReference.cache +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\DbSeer.dll +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\DbSeer.pdb +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\DbUp.dll +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.ConnectionInfo.dll +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.ConnectionInfoExtended.dll +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.Management.Sdk.Sfc.dll +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.Smo.dll +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.SmoExtended.dll +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.SqlClrProvider.dll +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\Microsoft.SqlServer.SqlEnum.dll +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\bin\Debug\DbUp.xml +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\obj\Debug\DbSeer.dll +c:\users\bholt\documents\visual studio 2013\Projects\DbSeer\DbSeer\obj\Debug\DbSeer.pdb diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbSeer.csprojResolveAssemblyReference.cache b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbSeer.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..a22513d Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbSeer.csprojResolveAssemblyReference.cache differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbSeer.dll b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbSeer.dll new file mode 100644 index 0000000..4d77f65 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbSeer.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbSeer.pdb b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbSeer.pdb new file mode 100644 index 0000000..3a1d7a4 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbSeer.pdb differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Scripting.csproj.FileListAbsolute.txt b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Scripting.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..3755cb3 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Scripting.csproj.FileListAbsolute.txt @@ -0,0 +1,14 @@ +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\bin\Debug\DbUp.Scripting.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\bin\Debug\DbUp.Scripting.pdb +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\bin\Debug\DbUp.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\bin\Debug\Microsoft.SqlServer.ConnectionInfo.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\bin\Debug\Microsoft.SqlServer.ConnectionInfoExtended.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\bin\Debug\Microsoft.SqlServer.Management.Sdk.Sfc.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\bin\Debug\Microsoft.SqlServer.Smo.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\bin\Debug\Microsoft.SqlServer.SmoExtended.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\bin\Debug\Microsoft.SqlServer.SqlClrProvider.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\bin\Debug\Microsoft.SqlServer.SqlEnum.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\bin\Debug\DbUp.xml +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\obj\Debug\DbUp.Scripting.csprojResolveAssemblyReference.cache +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\obj\Debug\DbUp.Scripting.dll +C:\Users\bholt\Documents\Visual Studio 2013\Projects\DbUp.Scripting\DbUp.Scripting\obj\Debug\DbUp.Scripting.pdb diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Scripting.csprojResolveAssemblyReference.cache b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Scripting.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..c403fe3 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Scripting.csprojResolveAssemblyReference.cache differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Scripting.dll b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Scripting.dll new file mode 100644 index 0000000..8e0bf03 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Scripting.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Scripting.pdb b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Scripting.pdb new file mode 100644 index 0000000..6ad6252 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Scripting.pdb differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.SqlServer.Scripting.csproj.FileListAbsolute.txt b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.SqlServer.Scripting.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..ce72e25 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.SqlServer.Scripting.csproj.FileListAbsolute.txt @@ -0,0 +1,14 @@ +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\obj\Debug\DbUp.SqlServer.Scripting.csprojResolveAssemblyReference.cache +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\obj\Debug\DbUp.Scripting.dll +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\obj\Debug\DbUp.Scripting.pdb +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\bin\Debug\DbUp.Scripting.dll +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\bin\Debug\DbUp.Scripting.pdb +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\bin\Debug\DbUp.dll +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.ConnectionInfo.dll +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.ConnectionInfoExtended.dll +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.Management.Sdk.Sfc.dll +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.Smo.dll +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.SmoExtended.dll +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.SqlClrProvider.dll +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.SqlEnum.dll +C:\dev\dbup-sqlserver-scripting\DbUp.SqlServer.Scripting\bin\Debug\DbUp.xml diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.SqlServer.Scripting.csprojResolveAssemblyReference.cache b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.SqlServer.Scripting.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..044b192 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.SqlServer.Scripting.csprojResolveAssemblyReference.cache differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Support.SqlServer.Scripting.csproj.FileListAbsolute.txt b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Support.SqlServer.Scripting.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..bbc25f1 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Support.SqlServer.Scripting.csproj.FileListAbsolute.txt @@ -0,0 +1,13 @@ +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\bin\Debug\DbUp.Support.SqlServer.Scripting.dll +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\bin\Debug\DbUp.Support.SqlServer.Scripting.pdb +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\bin\Debug\DbUp.dll +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.ConnectionInfo.dll +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.ConnectionInfoExtended.dll +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.Management.Sdk.Sfc.dll +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.Smo.dll +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.SmoExtended.dll +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.SqlClrProvider.dll +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\bin\Debug\Microsoft.SqlServer.SqlEnum.dll +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\bin\Debug\DbUp.xml +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\obj\Debug\DbUp.Support.SqlServer.Scripting.dll +C:\dev\dbup-sqlserver-scripting\DbUp.Support.SqlServer.Scripting\obj\Debug\DbUp.Support.SqlServer.Scripting.pdb diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Support.SqlServer.Scripting.dll b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Support.SqlServer.Scripting.dll new file mode 100644 index 0000000..e231e1c Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Support.SqlServer.Scripting.dll differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Support.SqlServer.Scripting.pdb b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Support.SqlServer.Scripting.pdb new file mode 100644 index 0000000..798891d Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DbUp.Support.SqlServer.Scripting.pdb differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/DbUp.Support.SqlServer.Scripting/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..4f3e490 Binary files /dev/null and b/DbUp.Support.SqlServer.Scripting/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/DbUp.Support.SqlServer.Scripting/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/DbUp.Support.SqlServer.Scripting/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/DbUp.Support.SqlServer.Scripting/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/DbUp.Support.SqlServer.Scripting/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/DbUp.Support.SqlServer.Scripting/packages.config b/DbUp.Support.SqlServer.Scripting/packages.config new file mode 100644 index 0000000..3d2e58c --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..80960ca --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Brady Holt + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..76affb9 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# DbUp SQL Server Object Scripting +SQL Server object definition scripting for [DbUp](http://dbup.github.io/). Distributed as a NuGet package. + +## Install + Install-Package dbup-sqlserver-scripting + diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..6970eeb --- /dev/null +++ b/Rakefile @@ -0,0 +1,35 @@ +#DbUp.ConsoleScripts +#Example usage: rake release[1.2.0,"Release notes here..."] + +require 'albacore' +require 'date' +require 'net/http' +require 'openssl' + +project_id = "dbup-sqlserver-scripting" +project_copyright = "Copyright #{DateTime.now.strftime('%Y')}" + +task :package, [:version_number, :notes] do |t, args| + desc "Download nuget.exe" + uri = URI.parse("https://api.nuget.org/downloads/nuget.exe") + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = true + http.verify_mode = OpenSSL::SSL::VERIFY_NONE # read into this + data = http.get(uri.request_uri) + open("nuget.exe", "wb") { |file| file.write(data.body) } + desc "create the nuget package" + sh "nuget.exe pack build\\#{project_id}.nuspec -Properties \"id=#{project_id};version=#{args.version_number};notes=v#{args.version_number} - #{args.notes};copyright=#{project_copyright}\"" +end + +task :push, [:version_number, :notes] do |t, args| + sh "nuget.exe push #{project_id}.#{args.version_number}.nupkg" +end + +task :tag, [:version_number, :notes] do |t, args| + sh "git tag -a v#{args.version_number} -m \"#{args.notes}\"" + sh "git push --tags" +end + +task :release, [:version_number, :notes] => [:package, :push, :tag] do |t, args| + puts "v#{args.version_number} Released!" +end \ No newline at end of file diff --git a/build/dbup-sqlserver-scripting.nuspec b/build/dbup-sqlserver-scripting.nuspec new file mode 100644 index 0000000..1f64deb --- /dev/null +++ b/build/dbup-sqlserver-scripting.nuspec @@ -0,0 +1,22 @@ + + + + $id$ + $version$ + DbUp SQL Server Object Scripting + Brady Holt + Brady Holt + https://raw.github.com/bradyholt/dbup-sqlserver-scripting/master/LICENSE + https://github.com/bradyholt/dbup-sqlserver-scripting + https://raw.github.com/DbUp/DbUp/master/src/Information/dbup-icon.png + false + SQL Server object definition scripting for DbUp + $notes$ + $copyright$ + dbup database migrations sqlserver scripting definitions scripts console + + + + + + diff --git a/build/tools/dbup-sqlserver-scripting.psm1 b/build/tools/dbup-sqlserver-scripting.psm1 new file mode 100644 index 0000000..a87b680 --- /dev/null +++ b/build/tools/dbup-sqlserver-scripting.psm1 @@ -0,0 +1,10 @@ +<# Package Manager Console scripts to support DbUp #> + +function Start-DatabaseScript { + $project = Get-Project + Write-Host "Building..." + $dte.Solution.SolutionBuild.BuildProject("Debug", $project.FullName, $true) + $projectDirectory = Split-Path $project.FullName + $projectExe = $projectDirectory + "\bin\Debug\" + $project.Name + ".exe" + " --scriptAllDefinitions" + iex $projectExe + } diff --git a/build/tools/init.ps1 b/build/tools/init.ps1 new file mode 100644 index 0000000..252d5dc --- /dev/null +++ b/build/tools/init.ps1 @@ -0,0 +1,3 @@ +param($installPath, $toolsPath, $package, $project) + +Import-Module (Join-Path $toolsPath dbup-sqlserver-scripting.psm1) \ No newline at end of file diff --git a/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.ConnectionInfo.dll b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.ConnectionInfo.dll new file mode 100644 index 0000000..9ceef99 Binary files /dev/null and b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.ConnectionInfo.dll differ diff --git a/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.ConnectionInfoExtended.dll b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.ConnectionInfoExtended.dll new file mode 100644 index 0000000..3363349 Binary files /dev/null and b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.ConnectionInfoExtended.dll differ diff --git a/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.Management.Sdk.Sfc.dll b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.Management.Sdk.Sfc.dll new file mode 100644 index 0000000..a59befb Binary files /dev/null and b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.Management.Sdk.Sfc.dll differ diff --git a/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.Smo.dll b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.Smo.dll new file mode 100644 index 0000000..19cf7b2 Binary files /dev/null and b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.Smo.dll differ diff --git a/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.SmoExtended.dll b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.SmoExtended.dll new file mode 100644 index 0000000..9a8f4f3 Binary files /dev/null and b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.SmoExtended.dll differ diff --git a/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.SqlClrProvider.dll b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.SqlClrProvider.dll new file mode 100644 index 0000000..f07af62 Binary files /dev/null and b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.SqlClrProvider.dll differ diff --git a/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.SqlEnum.dll b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.SqlEnum.dll new file mode 100644 index 0000000..54b9c1f Binary files /dev/null and b/packages/Unofficial.Microsoft.SQLServer.SMO.2014.12.0.2000.8/lib/Microsoft.SqlServer.SqlEnum.dll differ diff --git a/packages/dbup.3.2.1/lib/NET35/DbUp.XML b/packages/dbup.3.2.1/lib/NET35/DbUp.XML new file mode 100644 index 0000000..e1d4579 --- /dev/null +++ b/packages/dbup.3.2.1/lib/NET35/DbUp.XML @@ -0,0 +1,1334 @@ + + + + DbUp + + + + + Configuration extensions for the standard stuff. + + + + + Logs to a custom logger. + + + The logger. + + The same builder + + + + + Logs to the console using pretty colours. + + The builder. + + The same builder + + + + + Logs to the console using pretty colours. + + The builder. + + The same builder + + + + + Logs to System.Diagnostics.Trace. + + The builder. + + The same builder + + + + + Uses a custom journal for recording which scripts were executed. + + The builder. + The custom journal. + + The same builder + + + + + Adds a custom script provider to the upgrader. + + The builder. + The script provider. + + The same builder + + + + + Adds a static set of scripts to the upgrader. + + The builder. + The scripts. + + The same builder + + + + + Adds a static set of scripts to the upgrader. + + The builder. + The scripts. + + The same builder + + + + + Adds a single static script to the upgrader. + + The builder. + The script. + + The same builder + + + + + Adds a single static script to the upgrader. + + The builder. + The name of the script. This should never change once executed. + The script body. + + The same builder + + + + + Adds all scripts from a folder on the file system. + + The builder. + The directory path. + + The same builder + + + + + Adds all scripts from a folder on the file system, with a custom filter. + + The builder. + The directory path. + The filter. Use the static class to get some pre-defined filters. + + The same builder + + + + + Adds all scripts found as embedded resources in the given assembly. + + The builder. + The assembly. + + The same builder + + + + + Adds all scripts found as embedded resources in the given assembly, with a custom filter (you'll need to exclude non- .SQL files yourself). + + The builder. + The assembly. + The filter. Don't forget to ignore any non- .SQL files. + + The same builder + + + + + Adds all scripts found as embedded resources in the given assembly, or classes which inherit from IScript, with a custom filter (you'll need to exclude non- .SQL files yourself). + + The builder. + The assembly. + + The same builder + + + + + Adds all scripts found as embedded resources in the given assembly, or classes which inherit from IScript, with a custom filter (you'll need to exclude non- .SQL files yourself). + + The builder. + The assembly. + The Sql Script filter (only affects embdeeded scripts, does not filter IScript files). Don't forget to ignore any non- .SQL files. + + The same builder + + + + + Adds a preprocessor that can replace portions of a script. + + The builder. + The preprocessor. + + The same builder + + + + + Adds a set of variables that will be replaced before scripts are executed. + + The builder. + The variables. + + The same builder + + + + + Adds a single variable that will be replaced before scripts are executed. + + The builder. + The name of the variable. + The value to be substituted. + + + + + Sets a configuration flag which will cause the engine to skip variable expansion. + + The builder. + + + + + Sets a configuration flag which will cause the engine to perform variable expansion. + + The builder. + + + + + Allows you to set the execution timeout for scripts. + + The builder. + A TimeSpan value containing the timeout value or null. + The timeout value is less than zero or greater than 2,147,483,647 seconds. + Setting the timeout parameter to null will use the default timeout of the underlying provider. + + + + + Run creates a new connection for each script, without a transaction + + + + + + + Run DbUp in a single transaction + + + + + + + Run each script in it's own transaction + + + + + + + Represents the configuration of an UpgradeEngine. + + + + + Initializes a new instance of the class. + + + + + Ensures all expectations have been met regarding this configuration. + + + + + Adds variables to the configuration which will be substituted for every script + + The variables + + + + Manages your database connections, allowing you to control the use of transactions and the behaviour of those transactions + + + + + Gets or sets a log which captures details about the upgrade. + + + + + Gets a mutable list of script providers. + + + + + Gets a mutable list of script pre-processors. + + + + + Gets or sets the journal, which tracks the scripts that have already been run. + + + + + Gets or sets the script executor, which runs scripts against the underlying database. + + + + + A collection of variables to be replaced in scripts before they are run + + + + + Determines if variables should be replaced in scripts before they are run. + + + + + Builds a UpgradeEngine by accepting a list of callbacks to execute. For custom configuration, you should + implement extension methods on top of this class. + + + + + Adds a callback that will be run to configure the upgrader when Build is called. + + The configuration. + + + + Creates an UpgradeEngine based on this configuration. + + + + + + A fluent builder for creating database upgraders. + + + + + Returns the databases supported by DbUp. + + + + + Manages Sql Database Connections + + + + + Allows you to run an operation with a managed connection + + + + + Tells the connection manager it is starting an operation + + + + + Execute a lambda with the connection managed by the connection manager (i.e transactions, reusing connections etc) + + Action to execute + + + + Execute a lambda with the connection managed by the connection manager (i.e transactions, reusing connections etc) + + Action to execute + + + + Scripts often have multiple statements which have to be executed in their own commands. + + For example, MSSQL splits on GO, SQLite splits on ; etc. + + + + + Specifies the transaction strategy + + + + + Specifies whether the db script output should be logged + + + + + Manages Database Connections + + + + + Creates a database connection for the current database engine + + + + + Tells the connection manager is starting + + + + + Executes an action using the specfied transaction mode + + The action to execute + + + + Executes an action which has a result using the specfied transaction mode + + The action to execute + The result type + The result of the command + + + + Splits a script into commands, for example SQL Server separates command by the GO statement + + The script + A list of SQL Commands + + + + The transaction strategy that DbUp should use + + + + + Specifies whether the db script output should be logged + + + + + A class which represents a script, allowing you to dynamically generate a sql script at runtime + + + + + Provides the Sql Script to execute + + A factory to create open and active database commands + The Sql Script contents + + + + The transaction strategy being to be used by the DatabaseConnectionManager + + + + + Executes an action + + + + + + Executes an action which has a result + + + + + + + + Initialises the transaction strategy with the upgrade log + + + + + Represents a SQL Server script that is fetched at execution time, rather than discovery time + + + + + Represents a SQL Server script that comes from an embedded resource in an assembly. + + + + + Initializes a new instance of the class. + + The name. + The contents. + + + + + + + + + + + + + + + + + + + Gets the contents of the script. + + + + + + Gets the name of the script. + + + + + + Initializes a new instance of the class. + + The name. + The delegate which creates the content at execution time. + + + + Gets the contents of the script. + + + + + + Used for database engines that do not support schema's, it will remove $schema$. from all scripts + + + + + Preprocessor that executes before scripts are executed against the database + + + + + Performs some proprocessing step on a script + + + + + Performs some proprocessing step on a script + + + + + The transaction strategy to use + + + + + Run creates a new connection for each script, without a transaction + + + + + DbUp will run using a single transaction for the whole upgrade operation + + + + + DbUp will create a new connection and transaction per script + + + + + A factory class for filter methods. + + + + + This filter will exclude scripts that are listed in a file. + + + The file should contain a single script name per line. + + The file that contains the script names to be excluded, one per line. + + + + + This filter will only include scripts that are listed in a file. All other scripts will be excluded. + + + The file should contain a single script name per line. + + The file that contains the script names to be included, one per line. + + + + + This filter will exclude the specified scripts. + + The names of the scripts to be excluded. + + + + + This filter will include only the specified scripts, and exclude any others. + + The names of the scripts to be included. + + + + + Enables multiple executions of idempotent scripts. + + + + + This interface is provided to allow different projects to store version information differently. + + + + + Recalls the version number of the database. + + + + + + Records an upgrade script for a database. + + The script. + + + + Returns an empty array of length 0 + + + + + + Does not store the script, simply returns + + + + + + An implementation of the interface which tracks version numbers for a + Firebird database using a table called SchemaVersions. + + + + + Creates a new Firebird table journal. + + The Firebird connection manager. + The upgrade logger. + The name of the journal table. + + + + Fetches the list of already executed scripts. + + + + + + Records an upgrade script for a database. + + The script. + + + + An implementation of the interface which tracks version numbers for a + PostgreSQL database using a table called SchemaVersions. + + + + + Creates a new MySql table journal. + + The MySql connection manager. + The upgrade logger. + The name of the schema the journal is stored in. + The name of the journal table. + + + + Records an upgrade script for a database. + + The script. + + + + An implementation of the interface which tracks version numbers for a + PostgreSQL database using a table called SchemaVersions. + + + + + Creates a new PostgreSQL table journal. + + The PostgreSQL connection manager. + The upgrade logger. + The name of the schema the journal is stored in. + The name of the journal table. + + + + Records an upgrade script for a database. + + The script. + + + + Responsible for splitting SQL text into a list of commands. + + + + + Returns the seperate executable SQL commands within the SQL script. + + + + + + + Manages Sql Database Connections + + + + + Manages Sql Database Connections + + + + + + A helper for executing SQL queries easily. + + + + + Initializes a new instance of the class. + + The command factory. + The schema. + The additional script preprocessors. + Sets the variablesEnabled setting to true. + + + + Initializes a new instance of the class. + + The command factory. + The schema. + Function indicating true if variables should be replaced, false otherwise. + The additional script preprocessors. + + + + Adds a variable to be substituted on Adhoc script + + + + + + + + Executes a scalar query. + + The query. + The parameters. + + + + + Executes a query that returns the number of records modified. + + The query. + The parameters. + + + + + Executes a select query or procedure. + + The query. + The parameters. + + + + + Database Schema, should be null if database does not support schemas + + + + + A log that writes to the console in a colorful way. + + + + + Implemented by objects which record the internal details of the database migration. + + + + + Writes an informational message to the log. + + The format. + The args. + + + + Writes an error message to the log. + + The format. + The args. + + + + Writes a warning message to the log. + + The format. + The args. + + + + Writes an informational message to the log. + + The format. + The args. + + + + Writes an error message to the log. + + The format. + The args. + + + + Writes a warning message to the log. + + The format. + The args. + + + + This class orchestrates the database upgrade process. + + + + + Initializes a new instance of the class. + + The configuration. + + + + Determines whether the database is out of date and can be upgraded. + + + + + Tries to connect to the database. + + Any error message encountered. + + + + + Performs the database upgrade. + + + + + Returns a list of scripts that will be executed when the upgrade is performed + + The scripts to be executed + + + + Creates version record for any new migration scripts without executing them. + Useful for bringing development environments into sync with automated environments + + + + + + Represents the results of a database upgrade. + + + + + Initializes a new instance of the class. + + The scripts that were executed. + if set to true [successful]. + The error. + + + + Gets the scripts that were executed. + + + + + Gets a value indicating whether this is successful. + + + + + Gets the error. + + + + + This interface is implemented by classes that execute upgrade scripts against a database. + + + + + Executes the specified script against a database at a given connection string. + + The script. + + + + Executes the specified script against a database at a given connection string. + + The script. + Variables to replace in the script + + + + Verifies the specified schema exists and is valid + + + + + Timeout for each section of the script in seconds. If not set, the default timeout for the executor is used. + + + + + An enhanced implementation which retrieves upgrade scripts or IScript code upgrade scripts embedded in an assembly. + + + + + Provides scripts to be executed. + + + + + Gets all scripts that should be executed. + + + + + Initializes a new instance of the class. + + The assembly. + The embedded sql script filter. + + + + Gets all scripts that should be executed. + + + + + Allows backwards compatibility with previous API/behaviour of using connection factories with DbUp + + + + + Ctor for LegacySqlConnectionManager + + The connectionFactory + + + + No options are set. + + + + + Remove starting and ending white space from the object name. + + + + + Quotes the name of the SQLite object in square brackets to allow Special characters in the object name. + + Name of the object to quote. + The quoted object name with trimmed whitespace + + + + Quotes the name of the SQLite object in square brackets to allow Special characters in the object name. + + Name of the object to quote. + The settings which indicate if the whitespace should be dropped or not. + The quoted object name + + + + An implementation of the interface which tracks version numbers for a + SQLite database using a table called SchemaVersions. + + + + + An implementation of the interface which tracks version numbers for a + SQL Server database using a table called dbo.SchemaVersions. + + + + + Initializes a new instance of the class. + + The connection manager. + The log. + The schema that contains the table. + The table name. + + var journal = new TableJournal("Server=server;Database=database;Trusted_Connection=True", "dbo", "MyVersionTable"); + + + + + Recalls the version number of the database. + + All executed scripts. + + + + The Sql which gets + + + + + Records a database upgrade for a database specified in a given connection string. + + The script. + + + + The sql to exectute to create the schema versions table + + + + + + + Initializes a new instance of the class. + + + + + Create table sql for SQLite + + + + + + + Parses Sql Objects and performs quoting functions + + + + + Quotes the name of the SQL object in square brackets to allow Special characters in the object name. + This function implements System.Data.SqlClient.SqlCommandBuilder.QuoteIdentifier() with an additional + validation which is missing from the SqlCommandBuilder version. + + Name of the object to quote. + The quoted object name with trimmed whitespace + + + + Quotes the name of the SQL object in square brackets to allow Special characters in the object name. + This function implements System.Data.SqlClient.SqlCommandBuilder.QuoteIdentifier() with an additional + validation which is missing from the SqlCommandBuilder version. + + Name of the object to quote. + The settings which indicate if the whitespace should be dropped or not. + The quoted object name + + + + A standard implementation of the IScriptExecutor interface that executes against a SQL Server + database. + + + + + Initializes an instance of the class. + + + The logging mechanism. + The schema that contains the table. + Function that returns true if variables should be replaced, false otherwise. + Script Preprocessors in addition to variable substitution + + + + Executes the specified script against a database at a given connection string. + + The script. + + + + Verifies the existence of targeted schema. If schema is not verified, will check for the existence of the dbo schema. + + + + + Executes the specified script against a database at a given connection string. + + The script. + Variables to replace in the script + + + + SQLCommand Timeout in seconds. If not set, the default SQLCommand timeout is not changed. + + + + + Database Schema, should be null if database does not support schemas + + + + + Substitutes variables for values in SqlScripts + + + + + Initializes a new instance of the class. + + The variables. + + + + Substitutes variables + + + + + + Allows you to easily programatically supply scripts from code. + + + + + Initializes a new instance of the class. + + The scripts. + + + + Gets all scripts that should be executed. + + + + + The default implementation which retrieves upgrade scripts embedded in an assembly. + + + + + Initializes a new instance of the class. + + The assembly. + The filter. + + + + Gets all scripts that should be executed. + + + + + + Alternate implementation which retrieves upgrade scripts via a directory + + + + + + Path to SQL upgrade scripts + + + + + Path to SQL upgrade scripts + The filter. + + + + Gets all scripts that should be executed. + + + + + Used to create databases that are deleted at the end of a unit test. + + + + + Creates new TemporarySqlDatabase against (local) + + + + + Initializes a new instance of the class. + + The name. + + + + Creates the database. + + + + + Deletes the database. + + + + + Gets the connection string. + + The connection string. + + + + Gets a tool to run ad-hoc SQL queries. + + The ad hoc. + + + + A log that writes to System.Diagnostics.Trace. + + + + + Writes an informational message to the log. + + The format. + The args. + + + + Writes an error message to the log. + + The format. + The args. + + + + Writes a warning message to the log. + + The format. + The args. + + + + Configuration extension methods for SQL Server. + + + + + Creates an upgrader for SQL Server databases. + + Fluent helper type. + The connection string. + + A builder for a database upgrader designed for SQL Server databases. + + + + + Creates an upgrader for SQL Server databases. + + Fluent helper type. + The connection string. + The SQL schema name to use. Defaults to 'dbo'. + + A builder for a database upgrader designed for SQL Server databases. + + + + + Creates an upgrader for SQL Server databases. + + Fluent helper type. + The connection factory. + + A builder for a database upgrader designed for SQL Server databases. + + + + + Creates an upgrader for SQL Server databases. + + Fluent helper type. + The connection factory. + The SQL schema name to use. Defaults to 'dbo'. + + A builder for a database upgrader designed for SQL Server databases. + + + + + + + + + + + + + Tracks the list of executed scripts in a SQL Server table. + + The builder. + The schema. + The table. + + + + + Add extension methods to this type if you plan to add support for additional databases. + + + + + Reads SQL commands from an underlying text stream. + + + + diff --git a/packages/dbup.3.2.1/lib/NET35/DbUp.dll b/packages/dbup.3.2.1/lib/NET35/DbUp.dll new file mode 100644 index 0000000..ccf14aa Binary files /dev/null and b/packages/dbup.3.2.1/lib/NET35/DbUp.dll differ diff --git a/packages/repositories.config b/packages/repositories.config new file mode 100644 index 0000000..aef6cb3 --- /dev/null +++ b/packages/repositories.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file