IntelliJ IDEA 2026.2 Help

Liquibase

Prior to IntelliJ IDEA version 2024.1, some Liquibase features were only available with the JPA Buddy plugin. The following video demonstrates these features, which are now available with the Liquibase plugin.

To enable corresponding features, make sure that the project contains the Liquibase dependency. It also provides a number of actions to quickly generate changelogs, run them, preview SQL statements, and so on.

<dependency> <groupId>org.liquibase</groupId> <artifactId>liquibase-core</artifactId> </dependency>
dependencies { implementation 'org.liquibase:liquibase-core' }
dependencies { implementation("org.liquibase:liquibase-core") }

Initialize schema

With IntelliJ IDEA, you can initialize your database schema based on the mappings provided in your JPA entities. It will generate a set of DDL commands for your current entities in the form of a Liquibase changelog.

  1. Press Ctrl+Shift+A and start typing Liquibase Init Schema.

    You can also open a Liquibase changelog file, press Alt+Insert, and select Liquibase Init Schema. In this case, the opened file parameters will be used in the Changelog Preview window.

  2. To generate the DDL script based on the data model, select Model and specify the corresponding persistence unit.

    init-schema-changelog

    IntelliJ IDEA provides an option to create migration scripts specifically for changes in selected entity changes. In the Scope list, click Selected Entities and, in the Select Entities for Custom Scope window, choose entities.

    Custom scope

Changelog Preview Window

changelog-preview

If you want to save the changelog as a regular file, then the following configuration options will be available:

  • Directory and File name fields are responsible for configuring the location of the generated changelog. If a changelog with the specified name already exists, you will be prompted with a warning, after which the changes will be appended to that changelog.

  • You can use Include to, Include folder, and Include context to specify whether a changelog should be included in another changelog. If you check the Include folder box, it generates the include statement for the entire folder, not just the current changelog.

  • From the File type drop-down list, you can choose one of the four file types (YAML, JSON, SQL, XML) supported by Liquibase, in which IntelliJ IDEA will generate the changelog.

If you want to save the changelog as a scratch file, then you can configure only its name and type.

liquibase-preview-scratch

The left side of the window shows a preview of the changesets that will be generated. You can click on each change to see what it will look like. To combine several changes into one changeset or to ignore them, simply drag and drop them. The top left corner of the preview window contains various actions to modify the resulting changelog:

add-changelog-action

The following actions are provided:

  • Add Changelog — create a secondary changelog

  • Add Change Set — create a new changeset in the selected changelog

  • Remove from Changelog with options:

    • Remove from Changelog — simply remove the changes from the current changelog

    • Remove and Ignore — remove the changes and add them to Ignored, so they are excluded from future changesets too

    • Restore from Ignored — move the changes from Ignored to the changelog

  • Set Context (for changesets)

  • Set Labels (for changesets)

  • Show Other Actions — select all changes based on the danger level, expand/collapse all changes

Create empty changelog

  1. In the Project tool window, right-click the db/changelog directory.

  2. Select New (or press Alt+Insert) and select Liquibase Empty Changelog.

    Liquibase empty changelog
  3. In the New Liquibase Changelog dialog that opens, select an XML or YAML format for the changelog file.

    This will create a new file based on the Liquibase file template. You can check all available file templates in the IDE settings (Ctrl+Alt+S), under Editor | File and Code Templates.

IntelliJ IDEA provides you with coding assistance in XML and YAML Liquibase changelog files, including validation against the Liquibase schema, suggestion for known parameters, and navigation to property declarations and to included files.

Primary and Secondary Changelogs

IntelliJ IDEA lets you put the changes into two types of changelogs: Primary and Secondary. One use case for this is separating safe changes that can be run automatically and changes that require your attention and need to be run manually.

The changes can be separated automatically by their type (in Tools | Database Versioning | Diff Changes). Alternatively, you can create a secondary changelog manually in the Preview window using the Add Changelog action. Then you can simply drag the desired changesets into the new changelog.

By default, Primary and Secondary changelogs are generated in separate directories, which can be customized in the plugin settings. Read more in the IDE settings in the Tools | Database Versioning | Liquibase section.

Generate migration script

  1. If a database connection is not established, create one.

  2. In the Database tool window, right-click a database and select Create Liquibase Changelog.

    Create JPA Entities from DB

    Alternatively, open a JPA entity in the editor and do one the following:

    • Click JPA Entity icon in the gutter and select Create Liquibase Changelog.

    • Place the caret at an entity, press Alt+Enter to invoke intention actions, and select Create Liquibase Changelog.

  3. In the dialog that opens, select a source (the desired state of the data model) and target (the old state of the data model).

    You can choose between the following source options:

    • DB: should be used in case you have an up-to-date database and would like to generate migration scripts for updating another DB to the same state.

    • Model: use it to generate migration scripts representing the difference between the current state of the entity relationship model (JPA entities) and the old (target) state.

    The target can be set to:

    • DB — target DB with an older version of the schema.

    • Snapshot — use this option in case you have the desired state stored in a data model snapshot. It can be generated by IntelliJ IDEA as well.

  4. Click OK. IntelliJ IDEA will analyze the difference between Source and Target and show the Changelog Preview dialog.

    If you want to save the changelog as a regular file, then the following configuration options will be available:

    • In the Directory field, specify the location where you want to save the changelog file.

    • In the File name field, enter the name of a generated changelog file.

    • You can use Include to, Include folder, and Include context to specify whether a changelog should be included in another changelog. If you select the Include folder checkbox, it generates the include statement for the entire folder, not just the current changelog.

    • In the File type list, you can choose one of the four file types (YAML, JSON, SQL, XML) supported by Liquibase, in which IntelliJ IDEA will generate the changelog.

    If you want to save the changelog as a scratch file, select Scratch File on top of the Changelog Preview dialog and specify its name and type.

    changelog-preview

Navigate through changelog using the Structure tool window

If you have a lot of changesets in your Liquibase changelog file, the logical view of the Structure tool window can be useful to quickly preview the file and navigate through it. It shows change types as separate nodes, which you can expand to access more details.

The logical view is available for XML and YAML changelog files.

  1. With your changelog file opened in the editor, open the Structure tool window: View | Tools Windows | Structure.

    Alternatively, press Alt+7.

  2. In the Structure tool window, open the Logical tab.

    Click any change to navigate to its definition in the changelog file. For include and includeAll tags, you will be redirected to the changeset in the included file.

Structure tool window

Deploy the changes

Once your changelogs are ready, you can use a dedicated Liquibase run configuration to trigger the update and synchronize your database with your code. You can launch this run configuration from the run widget and from selected tool windows.

Run the update from the run widget

  • If the Liquibase run configuration is already selected in the widget, click Run.

    • Alternatively, press Shift+F10.

  • If another configuration is selected in the widget, click its name. In the popup that opens, find the Liquibase run configuration and click Run next to it.

    • Alternatively, press Alt+Shift+F10. In the popup that opens, select the Liquibase run configuration.

IntelliJ IDEA launches the Liquibase run configuration in the Run tool window.

Run the update from tool windows

You can launch the Liquibase run configuration from the following tool windows:

  • Persistence tool window:

    • Right-click a persistence unit, entity, or Liquibase changelog, and select Run Liquibase Update….

  • Database tool window:

    • Go to the toolbar and select Run Liquibase Update….

    • Right-click a database, schema, or table, and select Run Liquibase Update….

IntelliJ IDEA launches the Liquibase run configuration in the Run tool window.

Run the update from the root changelog

You can launch the Liquibase run configuration directly from your root changelog file if the spring.liquibase.change-log property in your application properties points to it.

  1. Open your root changelog file.

  2. In the gutter, click Run Liquibase Update….

    Location of the Run Liquibase Update icon in the gutter

IntelliJ IDEA launches the Liquibase run configuration in the Run tool window.

Liquibase run configuration

The Liquibase run configuration lets you deploy your changes to a connected database without having to run the whole application or use the terminal. Under the hood, this configuration runs the Liquibase update command.

Create a Liquibase run configuration

  1. Open the Run/Debug Configurations dialog:

    • In the main toolbar, click the run widget and select Edit Configurations….

    • Alternatively, go to Run | Edit Configurations….

  2. On the left side of the dialog, select Add New Configuration | Liquibase.

  3. Set up the run configuration options.

Liquibase run configuration options

Run configuration options

Item

Description

Name

Specify a name for the run configuration to quickly identify it among others when editing or running.

Store as project file

Save the run configuration settings to a file that you can share with other team members. The default location is .idea/runConfigurations. However, if you do not want to share the .idea directory, you can save the configuration to any other directory within the project.

By default, this option is disabled, and IntelliJ IDEA stores run configuration settings in .idea/workspace.xml.

Required options

Item

Description

Root changelog file

Specify the path to your root changelog file.

DB connection

Specify which database Liquibase should target when running the changelogs.

You need to select an existing data source from the Database tool window or create a new one by clicking .

Additional options

To add these options to your run configuration, select Modify options on the right side of the dialog and then select the relevant options from the list.

Item

Description

Context

Specify context filters to narrow down which changesets Liquibase will run during the update.

In case of multiple values, separate them with commas.

Labels

Specify label filters to narrow down which changesets Liquibase will run during the update.

In case of multiple values, separate them with commas.

Default schema

Specify the schema that Liquibase should manage.

Learn more about this setting from Liquibase's official documentation.

Liquibase schema

Specify the schema where Liquibase should create its tracking tables.

Learn more about this setting from Liquibase's official documentation.

Log level

Select the minimum severity level that should be logged during the update.

Learn more about this setting from Liquibase's official documentation.

Liquibase Settings

Liquibase plugin settings in the Settings dialog

Base settings

Item

Description

Liquibase version

Specify which Liquibase version you want to use in the project.

If you leave this field empty, the IDE will use the version from your build file.

Changeset author

Specify the value for the author attribute in generated changesets.

If you leave this field empty, the IDE will use the username from your operating system.

File type

Select which language to use when generating changelogs:

  • XML

  • YAML

  • JSON

  • SQL

Add empty rollback to changesets which don't support implicit one

Automatically add an empty rollback tag to any changeset whose change type does not support automatic rollbacks.

To learn how to write rollback statements, refer to the official Liquibase documentation.

Changelog Templates

Whenever an empty or differential Liquibase changelog is created, IntelliJ IDEA generates the file name based on the templates. You can configure primary/secondary directory and name of the changelogs.

The following variables and macros are available for the precise configuration:

  • #increment(<start>, <step>, <decimalFormat>): generate versions using a numeric sequence.

    • start: version number for the first migration

    • step: value to increase each version number by

    • decimalFormat: DecimalFormat pattern used to format the version number

  • #date(<simpleDateFormat>): generate versions using the current system date.

  • ${semVer.<getterMethod>}: generate versions using the semantic version from the project's build file.

    • getterMethod: method that extracts a specific segment of the semantic version. Here are examples for a 1.2.3-SNAPSHOT+build4 version:

      • ${semVer.getRawVersion()}: 1.2.3-SNAPSHOT+build4

      • ${semVer.getMajor()}: 1

      • ${semVer.getMinor()}: 2

      • ${semVer.getPatch()}: 3

      • ${semVer.getPreRelease()}: SNAPSHOT

DB Types

Sometimes software must provide support for a few DBMS types. In this case, Liquibase is the best choice, as it offers a cross-DB solution to declare DDL modifications. IntelliJ IDEA supports this solution as well. When generating cross-DB changelogs, it uses Liquibase properties to specify correct data types for each DBMS:

<property name="string.type" value="varchar" dbms="postgresql"/> <property name="string.type" value="nvarchar" dbms="mssql"/> <changeSet id="1622118750064-2" author="jpa-buddy"> <createTable tableName="owners"> <column autoIncrement="true" name="id" type="INT"> <constraints nullable="false" primaryKey="true" primaryKeyName="PK_OWNERS"/> </column> <column name="first_name" type="${string.type}(255)"/> <column name="last_name" type="${string.type}(255)"/> <column name="address" type="${string.type}(255)"/> <column name="city" type="${string.type}(255)"/> </createTable> </changeSet>

Therefore, there is no need to create separate changelogs for different DBMSes.

Changeset Templates

The Changeset Templates settings let you preconfigure commonly used changeset attributes for each change type. IntelliJ IDEA will automatically insert them into the relevant changesets every time you generate a changelog.

Item

Description

failOnError

Select what Liquibase should do if it encounters an error while executing the changeset:

  • If you select this option, Liquibase stops the update process.

  • If you clear this option, Liquibase suppresses the error and executes subsequent changesets.

runOnChange

Select what Liquibase should do if it detects that an already executed changeset has been modified:

  • If you select this option, Liquibase reruns the changeset.

  • If you clear this option, Liquibase throws an exception and stops the update process.

Create Preconditions

Automatically add relevant preconditions to the changeset and select what Liquibase should do if they are not met:

  • HALT: stop the update process.

  • CONTINUE: skip the changeset and execute subsequent changesets. On the next update, try to execute the skipped changeset again.

  • MARK_RAN: skip the changeset, mark it as executed, and execute subsequent changesets.

  • WARN: log a warning and execute the changeset regardless.

Additional features for Spring projects

On top of the standard Liquibase support provided by IntelliJ IDEA, projects based on the Spring framework can leverage additional IDE features.

Statuses of changelogs and changesets

Typically, if you want to check which changelogs were already applied, you need to either run Liquibase's change tracking commands or inspect its changelog table in your database. IntelliJ IDEA provides a faster alternative by displaying the statuses of your changes directly in the IDE.

Statuses of whole changelog files are displayed in the Project tool window (Alt+1).

Liquibase icons in the Project tool window with a checkmark for applied migration, exclamation mark for a failed migration

Each changelog is represented by the Liquibase logo (), and its status is reflected by a small icon in the logo's lower-right corner:

Icon

Status

Green checkmark icon

All changesets in the changelog were successfully applied to the database.

Red exclamation mark icon

The changelog was run, but one of its changesets failed.

You can find out more about the error by hovering over the file name.

Error details displayed in the Project tool window after hovering the mouse over an underlined changelog

To check which changeset caused the error, open the underlined changelog in the editor and look for a red exclamation mark in the gutter.

Red exclamation mark in the editor gutter next to a changeset

(None)

Status icons are not displayed in the following cases:

  • The changelog has not been run yet.

  • The changelog was run before, but one of the changesets failed.

Statuses of particular changesets are displayed in the editor gutter when you open a changelog file.

Status icons in the editor gutter of an opened changelog file

JPA Buddy features

You can install the JPA Buddy plugin to get even more support for Liquibase:

JPA Designer

The JPA Designer tool window lets you generate and modify code.

In the upper part of the tool window (JPA Palette), select an action for example, Create, and then double-click an element, for example, Table.

The lower part of the tool window (JPA Inspector) adapts to the selected element of the changelog, for example, a changeSet, and allows you to modify its attributes.

To learn more about JPA Designer, refer to Entity Designer.

JPA Designer

Editor toolbar

The Editor Toolbar provides fast access to relevant actions. It includes:

  1. An action to select the opened file in JPA Structure

  2. All actions from JPA Palette

  3. Init Schema Changelog action

  4. Diff Changelog action

jpa-palette-db-actions

JPA Buddy understands your data model and prefills the changesets as much as possible. And with the help of JPA Inspector you can explore the attributes of each changelog element:

liquibase-changelog-preview

Troubleshooting

Changelogs or changesets are displayed without status icons

This feature is only available in Spring projects. If your project does use Spring, make sure that:

17 July 2026