-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4bf0d3d
commit c9056a1
Showing
16 changed files
with
206 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.geekoosh.flyway.response; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.flywaydb.core.api.MigrationInfoService; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
|
||
public class Response { | ||
private static final Logger logger = LogManager.getLogger(Response.class); | ||
private ResponseInfo info; | ||
|
||
public Response(MigrationInfoService info) { | ||
this.info = new ResponseInfo(info); | ||
} | ||
|
||
public Response() {} | ||
|
||
public ResponseInfo getInfo() { | ||
return info; | ||
} | ||
|
||
public void setInfo(ResponseInfo info) { | ||
this.info = info; | ||
} | ||
|
||
public void log() { | ||
if(info == null) { | ||
logger.warn("No info available for this action"); | ||
return; | ||
} | ||
String logInfo = ""; | ||
if(info.getCurrent() != null) { | ||
logInfo = String.format("Current version: %s\n", | ||
info.getCurrent().getVersion().getVersion() | ||
); | ||
} | ||
if(info.getApplied() != null) { | ||
logInfo += String.format("Applied migrations: %s, %s\n", | ||
info.getApplied().length, | ||
Arrays.stream(info.getApplied()).map(my -> "(" + my.getVersion().getVersion() + " [" + my.getScript() + "])") | ||
.collect(Collectors.joining(", ")) | ||
); | ||
} | ||
if(info.getPending() != null) { | ||
logInfo += String.format("Pending migrations: %s, %s\n", | ||
info.getPending().length, | ||
Arrays.stream(info.getPending()).map(my -> "(" + my.getVersion().getVersion() + " [" + my.getScript() + "])") | ||
.collect(Collectors.joining(", ")) | ||
); | ||
} | ||
logger.info(logInfo); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/com/geekoosh/flyway/response/ResponseInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.geekoosh.flyway.response; | ||
|
||
import org.flywaydb.core.api.MigrationInfo; | ||
import org.flywaydb.core.api.MigrationInfoService; | ||
|
||
public class ResponseInfo { | ||
private MigrationInfo current; | ||
private MigrationInfo[] applied; | ||
private MigrationInfo[] pending; | ||
|
||
public ResponseInfo() { | ||
} | ||
|
||
public ResponseInfo(MigrationInfoService info) { | ||
this.current = info.current(); | ||
this.applied = info.applied(); | ||
this.pending = info.pending(); | ||
} | ||
|
||
public MigrationInfo getCurrent() { | ||
return current; | ||
} | ||
|
||
public void setCurrent(MigrationInfo current) { | ||
this.current = current; | ||
} | ||
|
||
public MigrationInfo[] getApplied() { | ||
return applied; | ||
} | ||
|
||
public void setApplied(MigrationInfo[] applied) { | ||
this.applied = applied; | ||
} | ||
|
||
public MigrationInfo[] getPending() { | ||
return pending; | ||
} | ||
|
||
public void setPending(MigrationInfo[] pending) { | ||
this.pending = pending; | ||
} | ||
} |
Oops, something went wrong.