Skip to content

Commit

Permalink
Add a warning that invalid locations will become an error in flyway 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyeeedar committed Mar 4, 2020
1 parent 0c2ed47 commit 7f977ae
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private Integer migrateGroup(boolean firstRun) {
Collections.reverse(resolved);
if (resolved.isEmpty()) {
LOG.warn("Schema " + schema + " has version " + currentSchemaVersion
+ ", but no migration could be resolved in the configured locations !");
+ ", but no migration could be resolved in the configured locations ! Note this warning will become an error in Flyway 7.");
} else {
for (MigrationInfo migrationInfo : resolved) {
// Only consider versioned migrations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ public Pair<Integer, String> call() {
} else {
LOG.info(String.format("Successfully validated %d migrations (execution time %s)",
count, TimeFormat.format(stopWatch.getTotalTimeMillis())));

if (count == 0) {
LOG.warn("No migrations found. Are your locations set up correctly?");
}
}
callbackExecutor.onEvent(Event.AFTER_VALIDATE);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private Set<String> findResourceNames() {
}

if (!locationResolved) {
LOG.warn("Unable to resolve location " + location);
LOG.warn("Unable to resolve location " + location + ". Note this warning will become an error in Flyway 7.");
}

return resourceNames;
Expand Down Expand Up @@ -233,15 +233,15 @@ private List<URL> getLocationUrlsForPath(Location location) {
urls = classLoader.getResources(location.getPath() + "/flyway.location");
if (!urls.hasMoreElements()) {
LOG.warn("Unable to resolve location " + location + " (ClassLoader: " + classLoader + ")"
+ " On WebSphere an empty file named flyway.location must be present on the classpath location for WebSphere to find it!");
+ " On WebSphere an empty file named flyway.location must be present on the classpath location for WebSphere to find it!\nNote this warning will become an error in Flyway 7.");
}
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
locationUrls.add(new URL(UrlUtils.decodeURL(url.toExternalForm()).replace("/flyway.location", "")));
}
} catch (IOException e) {
LOG.warn("Unable to resolve location " + location + " (ClassLoader: " + classLoader + ")"
+ " On WebSphere an empty file named flyway.location must be present on the classpath location for WebSphere to find it!");
+ " On WebSphere an empty file named flyway.location must be present on the classpath location for WebSphere to find it!\nNote this warning will become an error in Flyway 7.");
}
} else {
Enumeration<URL> urls;
Expand All @@ -251,7 +251,7 @@ private List<URL> getLocationUrlsForPath(Location location) {
locationUrls.add(urls.nextElement());
}
} catch (IOException e) {
LOG.warn("Unable to resolve location " + location + " (ClassLoader: " + classLoader + "): " + e.getMessage());
LOG.warn("Unable to resolve location " + location + " (ClassLoader: " + classLoader + "): " + e.getMessage() + "\nNote this warning will become an error in Flyway 7.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ public Collection<LoadableResource> scanForResources(Location location) {

File dir = new File(path);
if (!dir.exists()) {
LOG.warn("Skipping filesystem location:" + path + " (not found)");
LOG.warn("Skipping filesystem location:" + path + " (not found). Note this warning will become an error in Flyway 7.");
return Collections.emptyList();
}
if (!dir.canRead()) {
LOG.warn("Skipping filesystem location:" + path + " (not readable)");
LOG.warn("Skipping filesystem location:" + path + " (not readable). Note this warning will become an error in Flyway 7.");
return Collections.emptyList();
}
if (!dir.isDirectory()) {
LOG.warn("Skipping filesystem location:" + path + " (not a directory)");
LOG.warn("Skipping filesystem location:" + path + " (not a directory). Note this warning will become an error in Flyway 7.");
return Collections.emptyList();
}

Expand Down

0 comments on commit 7f977ae

Please sign in to comment.