DataBridge Documentation 2.0.17
A Java library for managing database connections and transactions
|
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 |
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.
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.
connection | The DatabaseConnection instance used to interact with the database. |
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.
SQLException | If there is an error querying the database. |
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.
migration | The migration to be applied. |
SQLException | If there is an error applying the migration or updating the changelog. |
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.
SQLException | If there is an error during the rollback process. |
void io.github.kdesp73.databridge.migration.Scheman.runMigrations | ( | ) | throws SQLException |
Runs all unapplied migrations, checking for any checksum mismatches and applying migrations as needed.
SQLException | If there is an error running the migrations. |
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.
SQLException | If there is an error reapplying migrations. |