public void Deploy(string schemaScriptsFolder, string repository = "", bool dropDatabase = false) { if (schemaScriptsFolder == string.Empty) { schemaScriptsFolder = Assembly.GetExecutingAssembly().Directory(); } if (!Directory.Exists(schemaScriptsFolder)) { throw new DirectoryNotFoundException( string.Format( "Database schema scripts folder {0}\r\ndoes not exist", schemaScriptsFolder)); } var roundhouseMigrate = new Migrate(); if (DatabaseFolderStructure != null) { DatabaseFolderStructure.SetMigrateFolders(roundhouseMigrate, schemaScriptsFolder); } if (databaseRestoreOptions != null) { databaseRestoreOptions.SetRunRestoreOptions(roundhouseMigrate); } roundhouseMigrate.Set(x => x.ConnectionString = this.ConnectionString) .Set(x => x.SqlFilesDirectory = schemaScriptsFolder) .Set(x => x.VersionFile = Path.Combine(schemaScriptsFolder, "_BuildInfo.txt")) .Set(x => x.WithTransaction = WithTransaction) .Set(x => x.Silent = true) .Set(x => x.RecoveryMode = RecoveryMode.NoChange) .Set(x => x.RepositoryPath = repository) .Set(x => x.WarnOnOneTimeScriptChanges = WarnOnOneTimeScriptChanges) .Set(x => x.DisableTokenReplacement = true) .Set(x => x.Drop = dropDatabase) .SetCustomLogging(logger); if (databaseRestoreOptions != null) { roundhouseMigrate.RunRestore(); } else { roundhouseMigrate.Run(); } }
public void Deploy(string schemaScriptsFolder, string repository = "", bool dropDatabase = false, TimeSpan?commandTimeout = null) { if (commandTimeout == null) { commandTimeout = TimeSpan.FromSeconds(30); } if (schemaScriptsFolder == string.Empty) { schemaScriptsFolder = Assembly.GetExecutingAssembly().Directory(); } if (!Directory.Exists(schemaScriptsFolder)) { throw new DirectoryNotFoundException( string.Format( "Database schema scripts folder {0}\r\ndoes not exist", schemaScriptsFolder)); } var roundhouseMigrate = new Migrate(); if (DatabaseFolderStructure != null) { DatabaseFolderStructure.SetMigrateFolders(roundhouseMigrate, schemaScriptsFolder); } if (databaseRestoreOptions != null) { databaseRestoreOptions.SetRunRestoreOptions(roundhouseMigrate); } roundhouseMigrate.Set(x => x.ConnectionString = ConnectionString) .Set(x => x.SqlFilesDirectory = schemaScriptsFolder) .Set(x => x.VersionFile = Path.Combine(schemaScriptsFolder, "_BuildInfo.txt")) .Set(x => x.WithTransaction = WithTransaction) .Set(x => x.Silent = true) .Set(x => x.CommandTimeout = Convert.ToInt32(commandTimeout.Value.TotalSeconds)) .Set(x => { if (!string.IsNullOrEmpty(OutputPath)) { x.OutputPath = OutputPath; } }) .Set(x => { var createDatabaseCustomScript = Path.Combine(schemaScriptsFolder, "CreateDatabase.sql"); if (File.Exists(createDatabaseCustomScript)) { x.CreateDatabaseCustomScript = createDatabaseCustomScript; } }) .Set(x => x.RecoveryMode = RecoveryMode.NoChange) .Set(x => x.RepositoryPath = repository) .Set(x => x.WarnOnOneTimeScriptChanges = WarnOnOneTimeScriptChanges) .Set(x => x.DisableTokenReplacement = true) .Set(x => x.Drop = dropDatabase) .Set(x => x.DisableOutput = true) .Set(x => x.DefaultEncoding = Encoding.Default) .SetCustomLogging(logger); if (databaseRestoreOptions != null) { roundhouseMigrate.RunRestore(); } else { roundhouseMigrate.Run(); } }