Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into DAT-7447
Browse files Browse the repository at this point in the history
  • Loading branch information
nvoxland committed Jan 21, 2022
2 parents 60bf3e1 + 235f70a commit 545632e
Show file tree
Hide file tree
Showing 68 changed files with 517 additions and 216 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/build.yml
Expand Up @@ -150,6 +150,32 @@ jobs:
path: |
*/target/*-0-SNAPSHOT.jar
sonar:
name: Sonar Scan
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'adopt'
cache: 'maven'
- name: Cache SonarCloud packages
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn clean verify sonar:sonar -P sonar -Dsonar.login=$SONAR_TOKEN

integration-test:
name: Integration Test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -308,7 +334,7 @@ jobs:
finish:
name: Finish Build
runs-on: ubuntu-latest
needs: [ setup, build, integration-test, package ]
needs: [ setup, build, integration-test, package, sonar ]
if: ${{ always() }}
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
# Liquibase [![Build and Test](https://github.com/liquibase/liquibase/actions/workflows/build.yml/badge.svg)](https://github.com/liquibase/liquibase/actions/workflows/build.yml)
# Liquibase [![Build and Test](https://github.com/liquibase/liquibase/actions/workflows/build.yml/badge.svg)](https://github.com/liquibase/liquibase/actions/workflows/build.yml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=liquibase&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=liquibase)
<p align="center"><img src="https://github.com/liquibase/liquibase/blob/master/Liquibase.png" width="30%" height="30%"></p>

Liquibase helps millions of teams track, version, and deploy database schema changes. It will help you to:
Expand Down
15 changes: 14 additions & 1 deletion changelog.txt
@@ -1,7 +1,20 @@
Liquibase Core Changelog
===========================================

Changes in version 4.7.0(2022.01.07)
Changes in version 4.7.1 (2022.01.21)

- Fix bug which makes Liquibase misidentify your database dialect if the string 'edb' is in your connection url. (#2364)
- Output changeset execution to UI like rollback does (#1932)
- Support MaxDB for sequences (#932)
- Include columnDataType in generated setColumnRemarks changesets (#2188)
- Use database time for changeloglock table (#2217)
- Mysql: support additional information "double" datatypes (#2293)
- Correctly handle old "liquibase tagExists myTag" style CLI structure (#2269)
- Correctly handle cacheSize in mariadb (#2270)
- Mark liquibase-maven-plugin logging configuration as deprecated (#2261)
- Added validation errors for SQLite and DB2z databases (#2359)

Changes in version 4.7.0 (2022.01.07)

Liquibase 4.7.0 introduces the init command with the project subcommand, which helps to build the necessary
configuration files for using Liquibase or, if you already use Liquibase, create new project files with minimal input.[DAT-8640]
Expand Down
Expand Up @@ -2,6 +2,9 @@

import liquibase.command.CommandResults;
import liquibase.command.CommandScope;
import liquibase.command.CommonArgumentNames;
import liquibase.exception.CommandValidationException;
import liquibase.exception.MissingRequiredArgumentException;
import liquibase.util.StringUtil;
import picocli.CommandLine;

Expand All @@ -10,7 +13,10 @@
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import java.util.stream.Stream;

class CommandRunner implements Callable<CommandResults> {

Expand Down Expand Up @@ -43,6 +49,17 @@ public CommandResults call() throws Exception {
}

return commandScope.execute();
} catch (CommandValidationException cve) {
Throwable cause = cve.getCause();
if (cause instanceof MissingRequiredArgumentException) {
// This is a list of the arguments which the init project command supports. The thinking here is that if the user
// forgets to supply one of these arguments, we're going to remind them about the init project command, which
// can help them figure out what they should be providing here.
final Set<String> initProjectArguments = Stream.of(CommonArgumentNames.CHANGELOG_FILE, CommonArgumentNames.URL, CommonArgumentNames.USERNAME, CommonArgumentNames.PASSWORD).map(CommonArgumentNames::getArgumentName).collect(Collectors.toSet());
throw new CommandValidationException(cve.getMessage() + (initProjectArguments.contains(((MissingRequiredArgumentException) cause).getArgumentName()) ? ". If you need to configure new liquibase project files and arguments, run the 'liquibase init project' command." : ""));
} else {
throw cve;
}
} finally {
if (outputStream != null) {
outputStream.flush();
Expand Down
Expand Up @@ -46,7 +46,7 @@ public Direction getDirection() {
public void visit(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database, Set<ChangeSetFilterResult> filterResults) throws LiquibaseException {
Executor executor = Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", database);
if (! (executor instanceof LoggingExecutor)) {
Scope.getCurrentScope().getUI().sendMessage("Rolling Back Changeset:" + changeSet);
Scope.getCurrentScope().getUI().sendMessage("Rolling Back Changeset: " + changeSet);
}
sendRollbackWillRunEvent(changeSet, databaseChangeLog, database);
try {
Expand Down
Expand Up @@ -10,6 +10,9 @@
import liquibase.database.ObjectQuotingStrategy;
import liquibase.exception.LiquibaseException;
import liquibase.exception.MigrationFailedException;
import liquibase.executor.Executor;
import liquibase.executor.ExecutorService;
import liquibase.executor.LoggingExecutor;

import java.util.Set;

Expand Down Expand Up @@ -40,8 +43,12 @@ public Direction getDirection() {
@Override
public void visit(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database,
Set<ChangeSetFilterResult> filterResults) throws LiquibaseException {
Executor executor = Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", database);
if (! (executor instanceof LoggingExecutor)) {
Scope.getCurrentScope().getUI().sendMessage("Running Changeset: " + changeSet);
}
ChangeSet.RunStatus runStatus = this.database.getRunStatus(changeSet);
Scope.getCurrentScope().getLog(getClass()).fine("Running Changeset:" + changeSet);
Scope.getCurrentScope().getLog(getClass()).fine("Running Changeset: " + changeSet);
fireWillRun(changeSet, databaseChangeLog, database, runStatus);
ExecType execType = null;
ObjectQuotingStrategy previousStr = this.database.getObjectQuotingStrategy();
Expand Down
Expand Up @@ -4,6 +4,7 @@
import liquibase.configuration.ConfigurationValueConverter;
import liquibase.configuration.ConfigurationValueObfuscator;
import liquibase.exception.CommandValidationException;
import liquibase.exception.MissingRequiredArgumentException;
import liquibase.integration.commandline.LiquibaseCommandLineConfiguration;
import liquibase.util.ObjectUtil;

Expand Down Expand Up @@ -113,7 +114,7 @@ public ConfigurationValueObfuscator<DataType> getValueObfuscator() {
public void validate(CommandScope commandScope) throws CommandValidationException {
final DataType currentValue = commandScope.getArgumentValue(this);
if (this.isRequired() && currentValue == null) {
throw new CommandValidationException(LiquibaseCommandLineConfiguration.ARGUMENT_CONVERTER.getCurrentValue().convert(this.getName()), "missing required argument");
throw new CommandValidationException(LiquibaseCommandLineConfiguration.ARGUMENT_CONVERTER.getCurrentValue().convert(this.getName()), "missing required argument", new MissingRequiredArgumentException(this.getName()));
}
}

Expand Down
Expand Up @@ -21,6 +21,13 @@ public <DataType> CommandArgumentDefinition.Building<DataType> argument(String n
return new CommandArgumentDefinition.Building<>(commandNames, new CommandArgumentDefinition<>(name, type));
}

/**
* Starts the building of a new {@link CommandArgumentDefinition}.
*/
public <DataType> CommandArgumentDefinition.Building<DataType> argument(CommonArgumentNames argument, Class<DataType> type) {
return new CommandArgumentDefinition.Building<>(commandNames, new CommandArgumentDefinition<>(argument.getArgumentName(), type));
}

/**
* Starts the building of a new {@link CommandResultDefinition}.
*/
Expand Down
@@ -0,0 +1,21 @@
package liquibase.command;

/**
* A common place to store commonly used command argument names.
*/
public enum CommonArgumentNames {
USERNAME("username"),
PASSWORD("password"),
URL("url"),
CHANGELOG_FILE("changelogFile");

private final String argumentName;

CommonArgumentNames(String argumentName) {
this.argumentName = argumentName;
}

public String getArgumentName() {
return argumentName;
}
}
Expand Up @@ -20,9 +20,9 @@ public class CalculateChecksumCommandStep extends AbstractCliWrapperCommandStep

static {
CommandBuilder builder = new CommandBuilder(COMMAND_NAME);
CHANGELOG_FILE_ARG = builder.argument("changelogFile", String.class).required()
CHANGELOG_FILE_ARG = builder.argument(CommonArgumentNames.CHANGELOG_FILE, String.class).required()
.description("The root changelog file").build();
URL_ARG = builder.argument("url", String.class).required()
URL_ARG = builder.argument(CommonArgumentNames.URL, String.class).required()
.description("The JDBC database connection URL").build();
DEFAULT_SCHEMA_NAME_ARG = builder.argument("defaultSchemaName", String.class)
.description("The default schema name to use for the database connection").build();
Expand All @@ -32,9 +32,9 @@ public class CalculateChecksumCommandStep extends AbstractCliWrapperCommandStep
.description("The JDBC driver class").build();
DRIVER_PROPERTIES_FILE_ARG = builder.argument("driverPropertiesFile", String.class)
.description("The JDBC driver properties file").build();
USERNAME_ARG = builder.argument("username", String.class)
USERNAME_ARG = builder.argument(CommonArgumentNames.USERNAME, String.class)
.description("The database username").build();
PASSWORD_ARG = builder.argument("password", String.class)
PASSWORD_ARG = builder.argument(CommonArgumentNames.PASSWORD, String.class)
.description("The database password")
.setValueObfuscator(ConfigurationValueObfuscator.STANDARD)
.build();
Expand Down
Expand Up @@ -21,9 +21,9 @@ public class ChangelogSyncCommandStep extends AbstractCliWrapperCommandStep {

static {
CommandBuilder builder = new CommandBuilder(COMMAND_NAME);
CHANGELOG_FILE_ARG = builder.argument("changelogFile", String.class).required()
CHANGELOG_FILE_ARG = builder.argument(CommonArgumentNames.CHANGELOG_FILE, String.class).required()
.description("The root changelog file").build();
URL_ARG = builder.argument("url", String.class).required()
URL_ARG = builder.argument(CommonArgumentNames.URL, String.class).required()
.description("The JDBC database connection URL").build();
DEFAULT_SCHEMA_NAME_ARG = builder.argument("defaultSchemaName", String.class)
.description("The default schema name to use for the database connection").build();
Expand All @@ -33,9 +33,9 @@ public class ChangelogSyncCommandStep extends AbstractCliWrapperCommandStep {
.description("The JDBC driver class").build();
DRIVER_PROPERTIES_FILE_ARG = builder.argument("driverPropertiesFile", String.class)
.description("The JDBC driver properties file").build();
USERNAME_ARG = builder.argument("username", String.class)
USERNAME_ARG = builder.argument(CommonArgumentNames.USERNAME, String.class)
.description("The database username").build();
PASSWORD_ARG = builder.argument("password", String.class)
PASSWORD_ARG = builder.argument(CommonArgumentNames.PASSWORD, String.class)
.description("The database password")
.setValueObfuscator(ConfigurationValueObfuscator.STANDARD)
.build();
Expand Down
Expand Up @@ -21,9 +21,9 @@ public class ChangelogSyncSqlCommandStep extends AbstractCliWrapperCommandStep {

static {
CommandBuilder builder = new CommandBuilder(COMMAND_NAME);
CHANGELOG_FILE_ARG = builder.argument("changelogFile", String.class).required()
CHANGELOG_FILE_ARG = builder.argument(CommonArgumentNames.CHANGELOG_FILE, String.class).required()
.description("The root changelog file").build();
URL_ARG = builder.argument("url", String.class).required()
URL_ARG = builder.argument(CommonArgumentNames.URL, String.class).required()
.description("The JDBC database connection URL").build();
DEFAULT_SCHEMA_NAME_ARG = builder.argument("defaultSchemaName", String.class)
.description("The default schema name to use for the database connection").build();
Expand All @@ -33,9 +33,9 @@ public class ChangelogSyncSqlCommandStep extends AbstractCliWrapperCommandStep {
.description("The JDBC driver class").build();
DRIVER_PROPERTIES_FILE_ARG = builder.argument("driverPropertiesFile", String.class)
.description("The JDBC driver properties file").build();
USERNAME_ARG = builder.argument("username", String.class)
USERNAME_ARG = builder.argument(CommonArgumentNames.USERNAME, String.class)
.description("The database username").build();
PASSWORD_ARG = builder.argument("password", String.class)
PASSWORD_ARG = builder.argument(CommonArgumentNames.PASSWORD, String.class)
.setValueObfuscator(ConfigurationValueObfuscator.STANDARD)
.description("The database password").build();
LABELS_ARG = builder.argument("labels", String.class)
Expand Down
Expand Up @@ -22,9 +22,9 @@ public class ChangelogSyncToTagCommandStep extends AbstractCliWrapperCommandStep

static {
CommandBuilder builder = new CommandBuilder(COMMAND_NAME);
CHANGELOG_FILE_ARG = builder.argument("changelogFile", String.class).required()
CHANGELOG_FILE_ARG = builder.argument(CommonArgumentNames.CHANGELOG_FILE, String.class).required()
.description("The root changelog file").build();
URL_ARG = builder.argument("url", String.class).required()
URL_ARG = builder.argument(CommonArgumentNames.URL, String.class).required()
.description("The JDBC database connection URL").build();
DEFAULT_SCHEMA_NAME_ARG = builder.argument("defaultSchemaName", String.class)
.description("The default schema name to use for the database connection").build();
Expand All @@ -34,9 +34,9 @@ public class ChangelogSyncToTagCommandStep extends AbstractCliWrapperCommandStep
.description("The JDBC driver class").build();
DRIVER_PROPERTIES_FILE_ARG = builder.argument("driverPropertiesFile", String.class)
.description("The JDBC driver properties file").build();
USERNAME_ARG = builder.argument("username", String.class)
USERNAME_ARG = builder.argument(CommonArgumentNames.USERNAME, String.class)
.description("The database username").build();
PASSWORD_ARG = builder.argument("password", String.class)
PASSWORD_ARG = builder.argument(CommonArgumentNames.PASSWORD, String.class)
.setValueObfuscator(ConfigurationValueObfuscator.STANDARD)
.description("The database password").build();
LABELS_ARG = builder.argument("labels", String.class)
Expand Down
Expand Up @@ -22,9 +22,9 @@ public class ChangelogSyncToTagSqlCommandStep extends AbstractCliWrapperCommandS

static {
CommandBuilder builder = new CommandBuilder(COMMAND_NAME);
CHANGELOG_FILE_ARG = builder.argument("changelogFile", String.class).required()
CHANGELOG_FILE_ARG = builder.argument(CommonArgumentNames.CHANGELOG_FILE, String.class).required()
.description("The root changelog file").build();
URL_ARG = builder.argument("url", String.class).required()
URL_ARG = builder.argument(CommonArgumentNames.URL, String.class).required()
.description("The JDBC database connection URL").build();
DEFAULT_SCHEMA_NAME_ARG = builder.argument("defaultSchemaName", String.class)
.description("The default schema name to use for the database connection").build();
Expand All @@ -34,9 +34,9 @@ public class ChangelogSyncToTagSqlCommandStep extends AbstractCliWrapperCommandS
.description("The JDBC driver class").build();
DRIVER_PROPERTIES_FILE_ARG = builder.argument("driverPropertiesFile", String.class)
.description("The JDBC driver properties file").build();
USERNAME_ARG = builder.argument("username", String.class)
USERNAME_ARG = builder.argument(CommonArgumentNames.USERNAME, String.class)
.description("The database username").build();
PASSWORD_ARG = builder.argument("password", String.class)
PASSWORD_ARG = builder.argument(CommonArgumentNames.PASSWORD, String.class)
.setValueObfuscator(ConfigurationValueObfuscator.STANDARD)
.description("The database password").build();
LABELS_ARG = builder.argument("labels", String.class)
Expand Down
Expand Up @@ -18,7 +18,7 @@ public class ClearChecksumsCommandStep extends AbstractCliWrapperCommandStep {

static {
CommandBuilder builder = new CommandBuilder(COMMAND_NAME);
URL_ARG = builder.argument("url", String.class).required()
URL_ARG = builder.argument(CommonArgumentNames.URL, String.class).required()
.description("The JDBC database connection URL").build();
DEFAULT_SCHEMA_NAME_ARG = builder.argument("defaultSchemaName", String.class)
.description("The default schema name to use for the database connection").build();
Expand All @@ -28,9 +28,9 @@ public class ClearChecksumsCommandStep extends AbstractCliWrapperCommandStep {
.description("The JDBC driver class").build();
DRIVER_PROPERTIES_FILE_ARG = builder.argument("driverPropertiesFile", String.class)
.description("The JDBC driver properties file").build();
USERNAME_ARG = builder.argument("username", String.class)
USERNAME_ARG = builder.argument(CommonArgumentNames.USERNAME, String.class)
.description("The database username").build();
PASSWORD_ARG = builder.argument("password", String.class)
PASSWORD_ARG = builder.argument(CommonArgumentNames.PASSWORD, String.class)
.setValueObfuscator(ConfigurationValueObfuscator.STANDARD)
.description("The database password").build();
}
Expand Down

0 comments on commit 545632e

Please sign in to comment.