protected void executeScriptsInDirectory(ConnectionSettings connectionSettings, String operation, DB db,
			String[] ignore) throws MojoFailureException, MojoExecutionException, IOException {

		BufferedWriter outputFileWriter = null;

		try {
			File scriptsDirectory = new File(this.scriptsDirectory, connectionSettings.getDatabase());
			scriptsDirectory = new File(scriptsDirectory, operation);

			if (!scriptsDirectory.exists()) {
				getLog().info("  no scripts found at: " + scriptsDirectory.getAbsolutePath());
				return;
			}

			File outputFile = new File(this.outputDirectory, this.outputName + "." + connectionSettings.getDatabase()
					+ "." + operation + SCRIPT_EXTENSION);
			if (outputFile.exists()) {
				getLog().info("  deleting: " + outputFile.getAbsolutePath());
				outputFile.delete();
			}

			getLog().info("  creating dir: " + outputFile.getParentFile().getAbsolutePath());
			outputFile.getParentFile().mkdirs();

			getLog().info("  creating: " + outputFile.getAbsolutePath());
			outputFile.createNewFile();

			outputFileWriter = new BufferedWriter(new FileWriter(outputFile));

			getLog().info("  executing scripts in: " + scriptsDirectory.getAbsolutePath());

			// make sure we can read it, and that it's
			// a directory and not a file
			if (!scriptsDirectory.isDirectory()) {
				throw new MojoFailureException(scriptsDirectory.getAbsolutePath() + " is not a directory");
			}

			// get all files in directory
			File[] files = scriptsDirectory.listFiles();

			// sort the scripts so that they execute in a reproducible order
			Arrays.sort(files, new Comparator<File>() {
				public int compare(File arg0, File arg1) {
					return arg0.getName().compareTo(arg1.getName());
				}
			});

			// loop through all the files and execute them unless they are to be
			// ignored
			List<String> ignoreList = Arrays.asList(ignore);
			for (int i = 0; i < files.length; i++) {
				if (!files[i].isDirectory() && files[i].isFile()) {
					File file = files[i];
					String fileName = file.getName();

					//
					// Skip files that don't end with SCRIPT_EXTENSION
					//
					if (!fileName.endsWith(SCRIPT_EXTENSION)) {
						getLog().info(
								"    file '" + fileName + "' ignored. Doesn't end with '" + SCRIPT_EXTENSION + "'");
						continue;
					}

					//
					// Skip files that are to be ignored
					//
					if (ignoreList.contains(fileName)) {
						getLog().info("    script '" + fileName + "' ignored. Already applied.");
						continue;
					}

					//
					// Execute the script
					//
					double startTime = System.currentTimeMillis();

					executeScript(files[i], db, outputFileWriter);

					double endTime = System.currentTimeMillis();
					double elapsed = ((endTime - startTime) / 1000.0);
					getLog().info("    script '" + fileName + "' completed execution in " + elapsed + " second(s)");
				}
			}

		} finally {
			if (null != outputFileWriter) {
				outputFileWriter.close();
				outputFileWriter = null;
			}
		}
	}