 	return REReplaceNoCase(arguments.version, "[^0-9]", "" ,"all");
 }
 
-/**
- * As migrator functions can be run within onApplicationStart, we need to check the scope
- */
-private struct function $getMigratorSettingsScope(){
-	return structKeyExists(application, "wheels") ? application.wheels : application.$wheels;
-}
-
 </cfscript>

public string function migrateTo(string version="") {
	local.rv = "";
	local.currentVersion = getCurrentMigrationVersion();
	local.settings = $getMigratorSettingsScope();
	if (local.currentVersion == arguments.version) {
		local.rv = "Database is currently at version #arguments.version#. No migration required.#chr(13)#";
	} else {
		if (!DirectoryExists(this.paths.sql) && local.settings.writeMigratorSQLFiles) {
			DirectoryCreate(this.paths.sql);
		}
		local.migrations = getAvailableMigrations();

							local.rv = local.rv & "#Chr(13)#-------- " & local.migration.cfcfile & " #RepeatString("-",Max(5,50-Len(local.migration.cfcfile)))##Chr(13)#";
							request.$wheelsMigrationOutput = "";
							request.$wheelsMigrationSQLFile = "#this.paths.sql#/#local.migration.cfcfile#_up.sql";
							if (application[local.appKey].writeMigratorSQLFiles) {
								FileWrite(request.$wheelsMigrationSQLFile, "");
							}
							local.migration.cfc.up();
