public void TestDoesNotRunSecondScriptIfFirstScriptFails() { this.EnsureTableDoesNotExist("TableWeWillUse"); this.EnsureTableDoesNotExist(TableName); var factory = new DbmsFactory(this.Dbms, this.ConnectionString); var dbmsSyntax = factory.CreateDbmsSyntax(); var output = new StringBuilder(); var applier = new TemplateBasedApplier( new StringWriter(output), dbmsSyntax, TableName, ";", DbDeployDefaults.DelimiterType, DbDeployDefaults.TemplateDirectory); applier.Apply(new ChangeScript[] { new StubChangeScript(1, "1.test.sql", "INSERT INTO TableWeWillUse VALUES (1);"), new StubChangeScript(2, "2.test.sql", "CREATE TABLE dbo.TableWeWillUse (Id int NULL);"), }, createChangeLogTable: true); using (var sqlExecuter = new SqlCmdExecutor(this.ConnectionString)) { var cmdOutput = new StringBuilder(); sqlExecuter.ExecuteString(output.ToString(), cmdOutput); } this.AssertTableDoesNotExist("TableWeWillUse"); }
private void CreateChangeLogTable(SqlCmdExecutor sqlCmdExecutor) { this.infoTextWriter.WriteLine("Creating change log table"); var output = new StringBuilder(); try { if (!sqlCmdExecutor.ExecuteString(this.dbmsSyntax.CreateChangeLogTableSqlScript(this.changeLogTableName), output)) { throw new DbDeployException(string.Format("Create ChangeLog Table '{0}' failed.", this.changeLogTableName)); } } finally { this.infoTextWriter.WriteLine(output); } }
public void TestDoesNotRunSecondScriptIfFirstScriptFails() { EnsureTableDoesNotExist("TableWeWillUse"); EnsureTableDoesNotExist(TableName); var factory = new DbmsFactory(Dbms, ConnectionString); var dbmsSyntax = factory.CreateDbmsSyntax(); var output = new StringBuilder(); var applier = new TemplateBasedApplier( new StringWriter(output), dbmsSyntax, TableName, ";", DbDeployDefaults.DelimiterType, DbDeployDefaults.TemplateDirectory); applier.Apply(new ChangeScript[] { new StubChangeScript(1, "1.test.sql", "INSERT INTO TableWeWillUse VALUES (1);"), new StubChangeScript(2, "2.test.sql", "CREATE TABLE dbo.TableWeWillUse (Id int NULL);"), }, true); using (var sqlExecuter = new SqlCmdExecutor(ConnectionString)) { var cmdOutput = new StringBuilder(); sqlExecuter.ExecuteString(output.ToString(), cmdOutput); } AssertTableDoesNotExist("TableWeWillUse"); }