Liquibase.Commands is a configuration file for Liquibase. This of this like appSettings.Json, web.config, global.asa.
Here is a sample of my Liquibase.Commands for an API project named Notes.
classpath=E:\\p\\liquibase\\internal\\lib\\mssql-jdbc.jar
driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
url=jdbc:sqlserver://127.0.0.1:1434;databaseName=notes;encrypt=false;user=liquibase_user;password=liquibase_user;
username=liquibase_user
password=liquibase_user
changeLogFile=notes.mssql.sql
where
- Classpath is where the liquibase was installed
- URL is a pointer to the database. It’s a JDBC formatted connection string
- User, password, username, password - database access. This account will need database structure access.
- changeLogFile - This gives a log of changes that have been applied to the database.
Liquibase init project
https://docs.liquibase.com/commands/init/project.html
Do this first to setup a liquibase project.
Start with a new subdirectory.
Execute liquibase init project.
It will ask the following questions
- Setup new liquibase.properties, flowfile, and sample changelog? Enter (Y)es with defaults, yes with (C)ustomization, or (N)o. [Y]:
I pressed enter. It created several files.
liquibase generate-changeLog –changelog-file=notes_changelog.xml
Can the database, script it out, and put all objects into the specified change log.
In addition, it will create 2 tables in the database, DATABASECHANGELOG, and DATABASECHANGELOGLOCK.
Future updates will compare changesets defined in the changelog file against records contained in DATABASECHANGELOG.
liquibase changelog-sync –changelog-file=notes_changelog.xml
This command instructs liquibase to update DATABASECHANGELOG with the changesets defined in the supplied changelog file.
This is used when you are adding liquibase to a database that already exists. You’ll execute a generate-changeLog, then you’ll execute a changelog-sync statment.
liquibase update
Compares the change log with the DATABASECHANGELOG table in the database. If it finds an id/author sequence not in that table, then it updates the database with the functions contained in that changeSet
If you do not specify a –changelog file, then it will use the file defined in liquibase-commands.