5.7 Liquibase Open-Source Changesets with SQLcl Liquibase
You can use changesets generated in the open-source Liquibase solution with SQLcl Liquibase. This enables you to carry over previous change management projects to SQLcl to optimize them with your Oracle Database.
The following example demonstrates this using the H2
database available in the open-source download of Liquibase and SQLcl Liquibase:
- Download the open-source Liquibase client available on
the Liquibase website. In your command-line interface, create a project folder and
example
H2database with the following command:>liquibase init project
- Start your
H2database:>liquibase init start-h2
This also launches the database console of the empty
H2database in your browser.
-
In the browser console, create a sample table using the following command and click Run:
>create table pets (id int, name varchar(256), breed varchar(256), Primary Key (id));
-
Capture this schema consisting of the
Petstable with a Liquibase changelog.Open a new command-line window and generate the changelog:
>liquibase --changelog-file=examplepets.xml generate-changelogName the changelog file as
examplepets.xml.
The output shows where the file is saved.
-
Connect to your Oracle Database from the SQLcl 22.3 bin location.
You can view the tables in your database with the following command. The example database shows a few sample tables.
SQL> select table_name from user_tables; TABLE_NAME ____________ REGIONS LOCATIONS DEPARTMENTS JOBS EMPLOYEES JOB_HISTORY COUNTRIES 7 rows selected. -
Copy the
examplepets.xmlchangelog file to the SQLcl 22.3 bin folder. -
In the SQL command-line interface, run the changelog to add the
Petstable to your database, and check to see that the table is now included in your list.SQL> lb update --changelog-file examplepets.xml SQL> select table_name from user_tables;