2

init project | Liquibase Docs

 1 year ago
source link: https://docs.liquibase.com/commands/init/project.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

init project

As a new user, run the init project subcommand to get started with Liquibase. If you already use Liquibase, run the subcommand to create a new project with a minimal input.

The subcommand finds or creates your project folder with a changelog and Liquibase properties file, liquibase.properties, and delivers an example H2 database to help you get started. When creating Liquibase project files, the init project subcommand includes parameters in the properties file, which you can alternatively run as CLI arguments, configure as environment variables, or specify as Java system properties.

Tip: The init project subcommand skips the CLI interactive mode when you provide values by other mechanisms than CLI.

Environment variable Liquibase properties file CLI parameter Description
LIQUIBASE_COMMAND_INIT
_PROJECT_PROJECT_DIR
liquibase.command.init
.project.projectDir
--project-dir Relative or fully qualified path to the directory where the project files will be created
LIQUIBASE_COMMAND_INIT
_PROJECT_FORMAT
liquibase.command.init
.project.format
--format Format of the project changelog file <.sql, .xml, .json, .yaml, .yml>
LIQUIBASE_COMMAND_INIT
_PROJECT_PROJECT_DEFAULTS_FILE
liquibase.command.init
.project.projectDefaultsFile
--project-defaults-file File with Liquibase properties.
LIQUIBASE_COMMAND_INIT
_PROJECT_CHANGELOG_FILE
liquibase.command.init
.project.changelog-file
--changelog-file Relative or fully qualified path to the changelog file.
LIQUIBASE_COMMAND_INIT
_PROJECT_PASSWORD
liquibase.command.init
.project.password
--password Password to use to connect to the database.
LIQUIBASE_COMMAND_INIT
_PROJECT_GUIDE
liquibase.command.init
.project.guide
--guide Parameter that turns on or turns off the CLI interactive mode. For example, if you want to set one parameter and have the rest as default ones, run the parameter and set --guide=off to not be asked about the rest of the settings: liquibase init project --changelog=mychangelog.sql --guide=off.
LIQUIBASE_COMMAND_INIT
_PROJECT_URL
liquibase.command.init
.project.url
--url Database connection URL (JDBC). For more information, see Using JDBC URL in Liquibase.
LIQUIBASE_COMMAND_INIT
_PROJECT_USERNAME
liquibase.command.init
.project.username
--username Username to use to connect to the database.

Note: An example of a Java system property:
For Windows, configure SET JAVA_OPTS="liquibase.command.init.project.projectDir=java_lbproj"
For Linux, run the value on the command line -Dliquibase.command.init.project.projectDir=java_lbproj

Running the init project subcommand

To run the init project subcommand in the interactive mode, enter liquibase init project and follow the command-line instructions: choose [y] to accept all the default values, [c] to customize the values, or [n] to not set up the project files.

The subcommand provides the following options:

  • Keep the default settings (y):
--project-dir=./
--changelog-file=example-changelog.sql
--format=sql
--project-defaults-file=liquibase.properties
--url=jdbc:h2:tcp://localhost:9090/mem:dev
--username=dbuser
--password=letmein

The default values work with the example H2 database, which is also delivered when running liquibase init project.

Customize all parameters (c):
--project-dir=[path/to/some/directory]
--changelog-file=[file.ext]
--format=[sql|xml|json|yaml|yml]
--project-defaults-file=[liquibase.properties]
--url=[some/JDBC/URL]
--username=[string]
--password=[string]
Customize a few parameters and stop the process. The default settings will be used.

Example: If you run liquibase init project --changelog-file=mychangelog.sql --username=myusername, the interactive mode will ask if you want to accept the rest of the default parameters or customize all flags that are not set. In this case, they are project dir, project defaults file, url, and password.

To run the init project subcommand in the non-interactive mode, run liquibase init project and specify all the parameters you need at once:

liquibase init project
--project-dir=[path/to/some/directory]
--changelog-file=[file.ext]
--format=[sql|xml|json|yaml|yml]
--project-defaults-file=[liquibase.properties]
--url=[some/JDBC/URL]
--username=[string]
--password=[string]

Note: If Liquibase cannot find the directory, it will create the directory using the path you have specified.

The subcommand does not overwrite your existing changelog file but updates an existing project-defaults-file with the same name. For example, this functionality might help you update the Liquibase properties file from the CLI with a different changelog or URL but keep other values and files the same.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK