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

Public Member Functions

int compareTo (Object other)
 
String getChecksum ()
 
String getChecksumUp ()
 
String getDescription ()
 
String getDownScript ()
 
String getFile ()
 
String getScript ()
 
String getUpScript ()
 
int getVersion ()
 
boolean isValid ()
 
 Migration (int version, String description)
 
 Migration (String path)
 
 Migration (String path, int version, String description, String upScript, String downScript)
 
String toShortString ()
 
String toString ()
 

Static Public Member Functions

static String generateChecksum (String script) throws IOException, NoSuchAlgorithmException
 
static void templateMigration () throws IOException
 

Detailed Description

The Migration class represents a database migration script, which includes versioning, descriptions, and the SQL scripts required for upgrading and downgrading a database schema.

A migration consists of an "up" script, which applies changes to the database, and a "down" script, which reverts those changes. Migrations are identified by a version number and a description.

The Migration class provides methods for reading migration files, validating migration data, generating checksums, and comparing migrations by version.

Author
KDesp73

Constructor & Destructor Documentation

◆ Migration() [1/3]

io.github.kdesp73.databridge.migration.Migration.Migration ( String path)

Constructs a Migration object by reading the migration script from the specified path.

Parameters
pathThe path to the migration script file.

◆ Migration() [2/3]

io.github.kdesp73.databridge.migration.Migration.Migration ( int version,
String description )

Constructs a Migration object with the specified version and description.

Parameters
versionThe version of the migration.
descriptionA description of the migration.

◆ Migration() [3/3]

io.github.kdesp73.databridge.migration.Migration.Migration ( String path,
int version,
String description,
String upScript,
String downScript )

Constructs a Migration object with the specified path, version, description, up script, and down script.

Parameters
pathThe path to the migration script file.
versionThe version of the migration.
descriptionA description of the migration.
upScriptThe SQL script for applying the migration.
downScriptThe SQL script for reverting the migration.

Member Function Documentation

◆ isValid()

boolean io.github.kdesp73.databridge.migration.Migration.isValid ( )

Validates the migration by ensuring it has a valid version and an "up" script.

Returns
true if the migration is valid, otherwise false.

◆ toString()

String io.github.kdesp73.databridge.migration.Migration.toString ( )

Returns a string representation of the Migration object, including all its properties.

Returns
A string representing the Migration object.

◆ getFile()

String io.github.kdesp73.databridge.migration.Migration.getFile ( )

Returns the file path of the migration script.

Returns
The file path of the migration script.

◆ getScript()

String io.github.kdesp73.databridge.migration.Migration.getScript ( )

Returns the full migration script, including version, description, up and down scripts.

Returns
The full migration script.

◆ getUpScript()

String io.github.kdesp73.databridge.migration.Migration.getUpScript ( )

Returns the "up" script of the migration.

Returns
The "up" script.

◆ getDownScript()

String io.github.kdesp73.databridge.migration.Migration.getDownScript ( )

Returns the "down" script of the migration.

Returns
The "down" script.

◆ getVersion()

int io.github.kdesp73.databridge.migration.Migration.getVersion ( )

Returns the version of the migration.

Returns
The version of the migration.

◆ getDescription()

String io.github.kdesp73.databridge.migration.Migration.getDescription ( )

Returns the description of the migration.

Returns
The description of the migration.

◆ getChecksum()

String io.github.kdesp73.databridge.migration.Migration.getChecksum ( )

Returns the checksum of the entire migration script.

Returns
The checksum of the migration script.

◆ getChecksumUp()

String io.github.kdesp73.databridge.migration.Migration.getChecksumUp ( )

Returns the checksum of the "up" script.

Returns
The checksum of the "up" script.

◆ generateChecksum()

static String io.github.kdesp73.databridge.migration.Migration.generateChecksum ( String script) throws IOException, NoSuchAlgorithmException
static

Generates the checksum of the provided script using MD5 hashing.

Parameters
scriptThe script to generate the checksum for.
Returns
The checksum of the script.
Exceptions
IOExceptionIf an I/O error occurs while processing the script.
NoSuchAlgorithmExceptionIf the MD5 algorithm is unavailable.

◆ compareTo()

int io.github.kdesp73.databridge.migration.Migration.compareTo ( Object other)

Compares this migration to another based on their version numbers.

Parameters
otherThe other migration to compare to.
Returns
A negative integer, zero, or a positive integer as this migration is less than, equal to, or greater than the other migration.

◆ toShortString()

String io.github.kdesp73.databridge.migration.Migration.toShortString ( )

Returns a string representing the path and version of this migration.

Returns
A string representing the migration path and version.

◆ templateMigration()

static void io.github.kdesp73.databridge.migration.Migration.templateMigration ( ) throws IOException
static

Generates a template migration file in the current working directory

Exceptions
IOException

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