Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/4.2.x' into 4.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
nvoxland committed Nov 12, 2020
2 parents 25455b9 + ab74e20 commit 2cbc9bd
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ protected DiffToChangeLog createDiffToChangeLogObject(DiffResult diffResult) {


protected void outputBestPracticeMessage() {
Scope.getCurrentScope().getUI().sendMessage("BEST PRACTICE: The changelog generated by diffChangeLog/generateChangeLog should be inspected for correctness and completeness before being deployed");
Scope.getCurrentScope().getUI().sendMessage(
"BEST PRACTICE: The changelog generated by diffChangeLog/generateChangeLog should be " +
"inspected for correctness and completeness before being deployed.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,12 @@ protected CommandResult run() throws Exception {
//
// Formatted SQL changelog
//
changeLogString = changeLogString.replaceFirst("--liquibase formatted sql",
"--liquibase formatted sql changeLogId:" + hubChangeLog.getId().toString());
String newChangeLogString = changeLogString.replaceFirst("--(\\s*)liquibase formatted sql",
"-- liquibase formatted sql changeLogId:" + hubChangeLog.getId().toString());
if (newChangeLogString.equals(changeLogString)) {
return new CommandResult("Unable to update changeLogId in changelog file '" + changeLogFile + "'", false);
}
changeLogString = newChangeLogString;
} else {
return new CommandResult("Changelog file '" + changeLogFile + "' is not a supported format", false);
}
Expand Down
26 changes: 16 additions & 10 deletions liquibase-core/src/main/java/liquibase/hub/core/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,23 @@ protected <T> T doRequest(String method, String url, Object requestBodyObject,
try {
try (InputStream error = connection.getErrorStream()) {
if (error != null) {
final Map errorDetails = yaml.load(error);

LiquibaseHubException returnException = new LiquibaseHubException((String) errorDetails.get("message"), e);

if (connection.getResponseCode() == 404) {
returnException = new LiquibaseHubObjectNotFoundException(returnException.getMessage(), returnException.getCause());
Object loadedObject = yaml.load(error);
if (loadedObject instanceof Map) {
final Map errorDetails = yaml.load(error);

LiquibaseHubException returnException = new LiquibaseHubException((String) errorDetails.get("message"), e);

if (connection.getResponseCode() == 404) {
returnException = new LiquibaseHubObjectNotFoundException(returnException.getMessage(), returnException.getCause());
}
returnException.setTimestamp((String) errorDetails.get("timestamp"));
returnException.setDetails((String) errorDetails.get("details"));
throw returnException;
}
else {
String errorMessage = "Unable to parse '" + loadedObject.toString() + "': " + e.getMessage();
throw new LiquibaseHubException(errorMessage, e.getCause());
}
returnException.setTimestamp((String) errorDetails.get("timestamp"));
returnException.setDetails((String) errorDetails.get("details"));
throw returnException;

}
}
} catch (IOException ioException) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package liquibase.snapshot.jvm;

import liquibase.CatalogAndSchema;
import liquibase.Scope;
import liquibase.database.AbstractJdbcDatabase;
import liquibase.database.Database;
import liquibase.database.core.InformixDatabase;
import liquibase.database.core.MySQLDatabase;
import liquibase.database.core.OracleDatabase;
import liquibase.exception.DatabaseException;
import liquibase.snapshot.CachedRow;
Expand Down Expand Up @@ -101,6 +103,15 @@ protected DatabaseObject snapshotObject(DatabaseObject example, DatabaseSnapshot
definition = StringUtil.trimToNull(definition);
if (definition == null) {
definition = "[CANNOT READ VIEW DEFINITION]";
if (database instanceof MySQLDatabase) {
String warningMessage =
"\nThe current MySQL user does not have permissions to access view definitions needed for this Liquibase command.\n" +
"Please search the changelog for '[CANNOT READ VIEW DEFINITION]' to locate inaccessible objects. This is\n" +
"potentially due to a known MySQL bug https://bugs.mysql.com/bug.php?id=22763. Learn more about altering\n" +
"permissions with suggested MySQL GRANTs at https://docs.liquibase.com/workflows/liquibase-pro/mysqlgrants.html\n";
Scope.getCurrentScope().getUI().sendMessage("WARNING: " + warningMessage);
Scope.getCurrentScope().getLog(getClass()).warning(warningMessage);
}
}

view.setDefinition(definition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ Hub integration CLI parameter
monitoring and reports in your Liquibase Hub
account. Get a free key at
https://hub.liquibase.com.
--hubConnectionId=<connectionId>
Used to identify the specific Connection in
which to record or extract data at Liquibase
Hub. Available in your Liquibase Hub Project
at https://hub.liquibase.com.
--hubProjectId=<projectId>
Used to identify the specific Project in which
to record or extract data at Liquibase Hub.
Available in your Liquibase Hub account at
https://hub.liquibase.com.
Documentation Commands
dbDoc <outputDirectory> Generates Javadoc-like documentation
Expand Down

0 comments on commit 2cbc9bd

Please sign in to comment.