3.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:

  1. Download the open-source Liquibase client available on the Liquibase website. In your command-line interface, create a project folder and example H2 database with the following command:
    >liquibase init project
    This is a code snippet.
  2. Start your H2 database:
    >liquibase init start-h2
    This is a code snippet.

    This also launches the database console of the empty H2 database in your browser.

    database console
  3. 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));
    create table command
  4. Capture this schema consisting of the Pets table with a Liquibase changelog.

    Open a new command-line window and generate the changelog:

    >liquibase --changelog-file=examplepets.xml generate-changelog

    Name the changelog file as examplepets.xml.

    This is a code snippet.

    The output shows where the file is saved.

  5. 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.
    
  6. Copy the examplepets.xml changelog file to the SQLcl 22.3 bin folder.

  7. In the SQL command-line interface, run the changelog to add the Pets table 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;
    This is a code snippet.