Skip to content

Commit

Permalink
Ignore commented lines (prefixed with --) in the migration scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
f511665 committed Sep 20, 2016
1 parent caeca4f commit d181e33
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -7,3 +7,5 @@ release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.idea
*.iml
Expand Up @@ -180,7 +180,7 @@ private String readResourceFileAsString(String resourceName, ClassLoader classLo
StringBuilder fileContent = new StringBuilder(256);
new BufferedReader(
new InputStreamReader(classLoader.getResourceAsStream(resourceName), SCRIPT_ENCODING))
.lines().forEach(fileContent::append);
.lines().filter(s -> !s.startsWith("--")).forEach(fileContent::append);
return fileContent.toString();
}

Expand Down
Expand Up @@ -77,4 +77,10 @@ public void shouldReturnCorrectVersionNumberWhenPathWithLeadingSlashGiven() {
assertThat(repository.getLatestVersion(), is(equalTo(0)));
}

@Test
public void shouldIgnoreComments() {
List<DbMigration> scripts = migrationRepository.getMigrationsSinceVersion(1);
assertThat(scripts.get(0).getMigrationScript().contains("--"), is(false));
}

}
@@ -1 +1,2 @@
--This is a comment
CREATE TABLE EVENTS (event_id uuid primary key, event_name varchar);

0 comments on commit d181e33

Please sign in to comment.