or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

changelog.mdcommand-framework.mdconfiguration.mddatabase-operations.mddatabase-support.mddiff-comparison.mdexceptions.mdindex.md
tile.json

tessl/maven-org-liquibase--liquibase-core

Liquibase is a tool for managing and executing database changes.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.liquibase/liquibase-core@5.0.x

To install, run

npx @tessl/cli install tessl/maven-org-liquibase--liquibase-core@5.0.0

index.mddocs/

Liquibase Database Migration Tool

Overview

Liquibase is a powerful database schema change management tool that provides version control for your database. It tracks, manages, and applies database schema changes in a structured, repeatable manner across different environments. Liquibase supports multiple database platforms and provides both programmatic APIs and command-line interfaces for database migrations, rollbacks, and schema management.

Package Information

  • Package Name: liquibase-core
  • Package Type: maven
  • Language: Java
  • Group ID: org.liquibase
  • Artifact ID: liquibase-core
  • Version: 5.0.0
  • Main Namespace: liquibase.*

Maven Dependency:

<dependency>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-core</artifactId>
    <version>5.0.0</version>
</dependency>

Gradle Dependency:

implementation 'org.liquibase:liquibase-core:5.0.0'

Direct JAR Download: Available from Maven Central

Core Imports

// Primary facade class
import liquibase.Liquibase;

// Modern command framework
import liquibase.command.CommandScope;
import liquibase.command.CommandResults;

// Database connection and management
import liquibase.database.Database;
import liquibase.database.DatabaseFactory;
import liquibase.database.DatabaseConnection;

// Changelog management
import liquibase.changelog.DatabaseChangeLog;
import liquibase.changelog.ChangeSet;

// Configuration
import liquibase.GlobalConfiguration;

// Resource access
import liquibase.resource.ResourceAccessor;
import liquibase.resource.ClassLoaderResourceAccessor;
import liquibase.resource.FileSystemResourceAccessor;

// Context and label filtering
import liquibase.Contexts;
import liquibase.LabelExpression;

// Exception handling
import liquibase.exception.LiquibaseException;
import liquibase.exception.DatabaseException;

Basic Usage

Simple Database Update

import liquibase.Liquibase;
import liquibase.database.DatabaseFactory;
import liquibase.database.jvm.JdbcConnection;
import liquibase.resource.ClassLoaderResourceAccessor;

// Create database connection
Connection connection = DriverManager.getConnection(
    "jdbc:h2:mem:test", "sa", ""
);
DatabaseConnection databaseConnection = new JdbcConnection(connection);
Database database = DatabaseFactory.getInstance()
    .findCorrectDatabaseImplementation(databaseConnection);

// Create Liquibase instance
Liquibase liquibase = new Liquibase(
    "changelog/db.changelog-master.xml",
    new ClassLoaderResourceAccessor(),
    database
);

// Execute update
liquibase.update((String) null);

// Close resources
liquibase.close();

Using Command Framework

import liquibase.command.CommandScope;

CommandScope updateCommand = new CommandScope("update")
    .addArgumentValue("changelogFile", "db/changelog/db.changelog-master.xml")
    .addArgumentValue("url", "jdbc:h2:mem:test")
    .addArgumentValue("username", "sa")
    .addArgumentValue("password", "");

CommandResults results = updateCommand.execute();

Architecture

Liquibase follows a layered architecture with clear separation of concerns:

Core Components

  • Liquibase Class: Main facade providing high-level operations
  • Command Framework: Modern command execution system via CommandScope
  • Database Layer: Abstraction over different database implementations
  • Changelog System: Management of database change definitions
  • Change Types: Specific database operations (create table, add column, etc.)
  • Resource Accessor: Flexible file and resource access system

Database Support

Liquibase provides native support for major database platforms including Oracle, MySQL, PostgreSQL, SQL Server, H2, SQLite, DB2, Derby, and many others through the Database interface and implementations.

Capabilities

Core Database Operations

Primary database migration operations using the main Liquibase class:

// Update operations
public void update() throws LiquibaseException
public void update(Contexts contexts) throws LiquibaseException  
public void update(Contexts contexts, LabelExpression labelExpression) throws LiquibaseException
public void update(int changesToApply, String contexts) throws LiquibaseException
public void update(String tag, String contexts) throws LiquibaseException

// Rollback operations  
public void rollback(int changesToRollback, String contexts) throws LiquibaseException
public void rollback(String tagToRollBackTo, String contexts) throws LiquibaseException
public void rollback(Date dateToRollBackTo, String contexts) throws LiquibaseException

// Status and validation
public List<ChangeSet> listUnrunChangeSets(Contexts contexts, LabelExpression labels) throws LiquibaseException
public void validate() throws LiquibaseException

// Database operations
public void dropAll() throws DatabaseException
public void tag(String tagString) throws LiquibaseException

→ See Database Operations for comprehensive API coverage

Command Framework

Modern command execution system for programmatic and CLI usage:

// Command construction and execution
public CommandScope(String... commandName) throws CommandExecutionException
public CommandScope addArgumentValue(String argumentName, Object value)
public CommandResults execute() throws CommandExecutionException

// Output control
public CommandScope setOutput(OutputStream outputStream)

→ See Command Framework for detailed command usage

Configuration System

Global configuration management for Liquibase behavior:

// Core configuration properties
public static final ConfigurationDefinition<String> DATABASECHANGELOG_TABLE_NAME
public static final ConfigurationDefinition<String> LIQUIBASE_CATALOG_NAME  
public static final ConfigurationDefinition<String> LIQUIBASE_SCHEMA_NAME
public static final ConfigurationDefinition<Boolean> VALIDATE_XML_CHANGELOG_FILES

→ See Configuration System for all settings and options

Changelog Management

Database change definition and management:

// DatabaseChangeLog management
public List<ChangeSet> getChangeSets()
public void addChangeSet(ChangeSet changeSet) 
public ChangeSet getChangeSet(String path, String author, String id)
public void validate(Database database, Contexts contexts, LabelExpression labelExpression)

// ChangeSet properties
public String getId()
public String getAuthor() 
public List<Change> getChanges()
public Contexts getContexts()
public Labels getLabels()

→ See Changelog Management for changeset creation and management

Database Support

Multi-database abstraction and platform-specific implementations:

// Database factory and detection
public static DatabaseFactory getInstance()
public Database findCorrectDatabaseImplementation(DatabaseConnection connection)
public Database openDatabase(String url, String username, String password, ...)

// Database interface
public boolean isCorrectDatabaseImplementation(DatabaseConnection conn)
public String getDatabaseProductName()
public String getDefaultCatalogName()
public boolean supportsAutoIncrement()

→ See Database Support for platform-specific features

Diff and Comparison

Schema comparison and change generation tools:

// Diff operations
public DiffResult diff(Database referenceDatabase, Database targetDatabase, CompareControl compareControl)

// Diff results
public Set<DatabaseObject> getMissingObjects()
public Set<DatabaseObject> getUnexpectedObjects() 
public Map<DatabaseObject, ObjectDifferences> getChangedObjects()
public boolean areEqual()

// Comparison control
public CompareControl(SchemaComparison[] schemaComparisons, Set<Class<? extends DatabaseObject>> compareTypes)

→ See Diff and Comparison for schema analysis tools

Exception Handling

Comprehensive exception hierarchy for error management:

// Base exceptions
public class LiquibaseException extends Exception
public class DatabaseException extends LiquibaseException
public class ValidationFailedException extends LiquibaseException

// Execution exceptions
public class CommandExecutionException extends LiquibaseException
public class MigrationFailedException extends LiquibaseException
public class RollbackFailedException extends LiquibaseException

// Parsing exceptions  
public class ChangeLogParseException extends LiquibaseException
public class LiquibaseParseException extends LiquibaseException

→ See Exception Handling for complete error management

Related Documentation