DataBridge Documentation 2.0.17
A Java library for managing database connections and transactions
Loading...
Searching...
No Matches
io.github.kdesp73.databridge.migration.Scheman Class Reference

Public Member Functions

void applyMigration (Migration migration) throws SQLException
 
void cli ()
 
int getCurrentVersion () throws SQLException
 
void rerunMigrations () throws SQLException
 
void rollbackMigration () throws SQLException
 
void runMigrations () throws SQLException
 
 Scheman (DatabaseConnection connection)
 
ResultSet selectMigrations () throws SQLException
 

Detailed Description

The Scheman class handles the database schema migrations. It provides methods for applying, rolling back, and verifying migrations. The class also manages the schema changelog to track the versions and checksums of the migrations applied to the database.

It interacts with the database through a DatabaseConnection instance and uses migration scripts stored in a designated migrations directory.

Author
kdesp73

Constructor & Destructor Documentation

◆ Scheman()

io.github.kdesp73.databridge.migration.Scheman.Scheman ( DatabaseConnection connection)

Constructs a new Scheman instance with the provided database connection. Initializes the schema changelog and verifies the existence of the changelog table.

Parameters
connectionThe DatabaseConnection instance used to interact with the database.

Member Function Documentation

◆ getCurrentVersion()

int io.github.kdesp73.databridge.migration.Scheman.getCurrentVersion ( ) throws SQLException

Returns the current version of the schema by querying the version from the schema changelog table.

Returns
The current schema version.
Exceptions
SQLExceptionIf there is an error querying the database.

◆ applyMigration()

void io.github.kdesp73.databridge.migration.Scheman.applyMigration ( Migration migration) throws SQLException

Applies the given migration to the database by executing its up script and inserting a record into the schema changelog table.

Parameters
migrationThe migration to be applied.
Exceptions
SQLExceptionIf there is an error applying the migration or updating the changelog.

◆ rollbackMigration()

void io.github.kdesp73.databridge.migration.Scheman.rollbackMigration ( ) throws SQLException

Rolls back the most recent migration by executing its down script and removing its record from the schema changelog table.

Exceptions
SQLExceptionIf there is an error during the rollback process.

◆ runMigrations()

void io.github.kdesp73.databridge.migration.Scheman.runMigrations ( ) throws SQLException

Runs all unapplied migrations, checking for any checksum mismatches and applying migrations as needed.

Exceptions
SQLExceptionIf there is an error running the migrations.

◆ rerunMigrations()

void io.github.kdesp73.databridge.migration.Scheman.rerunMigrations ( ) throws SQLException

Reapplies any migrations that have been modified after they were first applied, based on checksum mismatches.

Exceptions
SQLExceptionIf there is an error reapplying migrations.

The documentation for this class was generated from the following file: