Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/DAT-8601' into dependabot/maven/…
Browse files Browse the repository at this point in the history
…liquibase-dist/com.h2database-h2-2.0.202
  • Loading branch information
suryaaki committed Dec 27, 2021
2 parents 2ff4e20 + d7ebf6e commit 94f38a3
Show file tree
Hide file tree
Showing 36 changed files with 694 additions and 76 deletions.
Expand Up @@ -468,7 +468,6 @@ public int getPrecedence() {
Scope.getCurrentScope().getLog(getClass()).fine("Cannot find local defaultsFile " + defaultsFile.getAbsolutePath());
}


return returnList;
}

Expand Down
Expand Up @@ -58,6 +58,13 @@ public CommandDefinition getCommand() {
return commandDefinition;
}

/**
* Returns the complete config prefix (without a trailing period) for the command in this scope.
* @return
*/
public String getCompleteConfigPrefix() {
return completeConfigPrefix;
}

/**
* Adds the given key/value pair to the stored argument data.
Expand Down
Expand Up @@ -26,7 +26,7 @@ public class UpdateCommandStep extends AbstractCliWrapperCommandStep {
CommandBuilder builder = new CommandBuilder(COMMAND_NAME, LEGACY_COMMAND_NAME);

URL_ARG = builder.argument("url", String.class).required()
.description("The JDBC database connection URL").build();
.description("The JDBC database connection URL").build();
DEFAULT_SCHEMA_NAME = builder.argument("defaultSchemaName", String.class)
.description("The default schema name to use for the database connection").build();
DEFAULT_CATALOG_NAME_ARG = builder.argument("defaultCatalogName", String.class)
Expand Down
Expand Up @@ -45,7 +45,6 @@ public DataType getValueObfuscated() {
return rawValue;
}


/**
* Returns the "winning" value across all the possible {@link ConfigurationValueProvider}.
* A {@link ProvidedValue} is always returned, even if the value was not configured.
Expand All @@ -56,15 +55,16 @@ public ProvidedValue getProvidedValue() {
return getProvidedValues().get(0);
}


/**
*
* Return true if a default value was the "winning" value
*
* @return boolean
*
*/
public boolean wasDefaultValueUsed() {
for (ProvidedValue providedValue : this.getProvidedValues()) {
if (providedValue.getProvider() != null && providedValue.getProvider() instanceof ConfigurationDefinition.DefaultValueProvider) {
return true;
}
}

return false;
ProvidedValue winningProvidedValue = getProvidedValue();
return winningProvidedValue != null && winningProvidedValue.getProvider() instanceof ConfigurationDefinition.DefaultValueProvider;
}

/**
Expand Down
Expand Up @@ -113,7 +113,7 @@ public <T> T prompt(String prompt, T valueIfNoEntry, InputHandler<T> inputHandle
message = "Invalid value: \"" + input + "\"";
}
this.sendMessage(message);
this.sendMessage(prompt + ": ");
this.sendMessage(initialMessage + ": ");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion liquibase-core/src/main/java/liquibase/util/FileUtil.java
Expand Up @@ -11,7 +11,7 @@ private FileUtil() {
throw new IllegalStateException("This utility class must not be instantiated. Sorry.");
}

public static String getContents(File file) throws IOException {
public static String getContents(File file) throws IOException {
if (!file.exists()) {
return null;
}
Expand Down
@@ -0,0 +1,18 @@
{ "databaseChangeLog": [
"changeset": {
"id": "1",
"author": "your.name",
"changes": [
{
}
]
},
"changeset": {
"id": "2",
"author": "your.name",
"changes": [
{
}
]
}
]}
@@ -0,0 +1,120 @@
{ "databaseChangeLog": [
{
"changeSet": {
"id": "1",
"author": "your.name",
"changes": [
{
"createTable": {
"tableName": "person",
"columns": [
{
"column": {
"name": "id",
"type": "int",
"autoIncrement": true,
"constraints": {
"primarykey": true,
"nullable": false
}
}
},
{
"column": {
"name": "name",
"type": "varchar(50)"
}
},
{
"column": {
"name": "addresss1",
"type": "varchar(50)"
}
},
{
"column": {
"name": "addresss2",
"type": "varchar(50)"
}
},
{
"column": {
"name": "city",
"type": "varchar(30)"
}
}
]
}
}]
}
},
{
"changeSet": {
"id": "2",
"author": "your.name",
"changes": [
{
"createTable": {
"tableName": "company",
"columns": [
{
"column": {
"name": "id",
"type": "int",
"autoIncrement": true,
"constraints": {
"primarykey": true,
"nullable": false
}
}
},
{
"column": {
"name": "name",
"type": "varchar(50)"
}
},
{
"column": {
"name": "addresss1",
"type": "varchar(50)"
}
},
{
"column": {
"name": "addresss2",
"type": "varchar(50)"
}
},
{
"column": {
"name": "city",
"type": "varchar(30)"
}
}
]
}
}]
}
},
{
"changeSet": {
"id": "3",
"author": "your.name",
"changes": [
{
"addColumn": {
"tableName": "company",
"columns": [
{
"column": {
"name": "country",
"type": "varchar(2)"
}
}
]
}
}]
}
}
]}
@@ -0,0 +1,30 @@
"changeSet": {
"id": "1",
"author": "dev",
"changes": [
{
"createTable": {
"tableName": "person",
"columns": [
{
"column": {
"name": "id",
"type": "int",
"autoIncrement": true,
"constraints": {
"primaryKey": true,
"nullable": false
}
}
},
{
"column": {
"name": "name",
"type": "varchar(255)"
}
}
]
}
}
]
}
Expand Up @@ -20,7 +20,7 @@
## The url H2 example below is relative to 'pwd' resource.
####
# Enter the path for your changelog file.
changeLogFile=samplechangelog.h2.sql
changeLogFile=example-changelog.json

#### Enter the Target database 'url' information ####
liquibase.command.url=jdbc:h2:tcp://localhost:9090/mem:dev
Expand Down
@@ -0,0 +1,7 @@
(example-changeset-sql.txt)

--changeset dev:1
create table test1(
id int primary key,
name varchar(255)
);
Expand Up @@ -20,7 +20,7 @@
## The url H2 example below is relative to 'pwd' resource.
####
# Enter the path for your changelog file.
changeLogFile=sample.changelog.xml
changeLogFile=example-changelog.sql

#### Enter the Target database 'url' information ####
liquibase.command.url=jdbc:h2:tcp://localhost:9090/mem:dev
Expand Down
41 changes: 41 additions & 0 deletions liquibase-core/src/main/resources/liquibase/examples/start-h2
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

if [ -z "${LIQUIBASE_HOME}" ]; then
#liquibase home is not set

LIQUIBASE_PATH="$(which liquibase)"

if [ -z "${LIQUIBASE_PATH}" ]; then
echo "Must set LIQUIBASE_HOME environment variable, or have liquibase in your PATH"
exit 1
fi

LIQUIBASE_HOME=$(dirname "$(which liquibase)")
fi

if [ -z "${JAVA_HOME}" ]; then
#JAVA_HOME not set, try to find a bundled version
if [ -d "${LIQUIBASE_HOME}/jre" ]; then
JAVA_HOME="$LIQUIBASE_HOME/jre"
elif [ -d "${LIQUIBASE_HOME}/.install4j/jre.bundle/Contents/Home" ]; then
JAVA_HOME="${LIQUIBASE_HOME}/.install4j/jre.bundle/Contents/Home"
fi
fi

if [ -z "${JAVA_HOME}" ]; then
JAVA_PATH="$(which java)"

if [ -z "${JAVA_PATH}" ]; then
echo "Cannot find java in your path. Install java or use the JAVA_HOME environment variable"

exit 1
fi
else
#Use path in JAVA_HOME
JAVA_PATH="${JAVA_HOME}/bin/java"
fi


# echo "${JAVA_PATH}" -cp "${LIQUIBASE_HOME}/lib/h2-1.4.200.jar:${LIQUIBASE_HOME}/liquibase.jar" liquibase.example.StartH2Main

"${JAVA_PATH}" -cp "${LIQUIBASE_HOME}/lib/h2-1.4.200.jar:${LIQUIBASE_HOME}/liquibase.jar" liquibase.example.StartH2Main
34 changes: 34 additions & 0 deletions liquibase-core/src/main/resources/liquibase/examples/start-h2.bat
@@ -0,0 +1,34 @@
@echo off
if "%OS%" == "Windows_NT" setlocal

setlocal enabledelayedexpansion

rem %~dp0 is expanded pathname of the current script under NT
rem %~p0 is the directory of the current script

if exist %~p0\..\liquibase.jar SET LIQUIBASE_HOME="%~p0\.."

if "%LIQUIBASE_HOME%"=="" (
FOR /F "tokens=* USEBACKQ" %%g IN (`where liquibase.bat`) do (SET "LIQUIBASE_HOME=%%~dpg")
)

if "%LIQUIBASE_HOME%"=="" (
echo "Must set LIQUIBASE_HOME environment variable, or have liquibase.bat in your PATH"
exit /B 1
)

if "%JAVA_HOME%"=="" (

rem check for jre dir in liquibase_home
if NOT "%LIQUIBASE_HOME%"=="" if exist "%LIQUIBASE_HOME%\jre" (
set JAVA_HOME=%LIQUIBASE_HOME%\jre
)
)

if "%JAVA_HOME%"=="" (
set JAVA_PATH=java
) else (
set JAVA_PATH=%JAVA_HOME%\bin\java
)

"%JAVA_PATH%" -cp "%LIQUIBASE_HOME%\lib\h2-1.4.200.jar;%LIQUIBASE_HOME%\liquibase.jar" liquibase.example.StartH2Main
Expand Up @@ -8,11 +8,11 @@
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.6.xsd ">

<changeSet id="1" author="author name">
<!--Insert XML changes objects here https://www.liquibase.org/documentation/xml_format.html-->
<!--Insert XML change objects here https://www.liquibase.org/documentation/xml_format.html-->
</changeSet>

<changeSet id="2" author="author name">
<!--Insert XML changes objects here https://www.liquibase.org/documentation/xml_format.html-->
<!--Insert XML change objects here https://www.liquibase.org/documentation/xml_format.html-->
</changeSet>

</databaseChangeLog>
@@ -0,0 +1,13 @@
<changeSet id="1" author="your.name">
<createTable tableName="person">
<column name="id" type="int">
<constraints primaryKey="true"/>
</column>
<column name="name" type="varchar(50)">
<constraints nullable="false"/>
</column>
<column name="address1" type="varchar(50)"/>
<column name="address2" type="varchar(50)"/>
<column name="city" type="varchar(30)"/>
</createTable>
</changeSet>

0 comments on commit 94f38a3

Please sign in to comment.