MySQL database type plugin for Flyway database migration engine providing specialized MySQL and MariaDB support for schema migrations.
npx @tessl/cli install tessl/maven-org-flywaydb--flyway-mysql@11.8.0Flyway MySQL is a database type plugin that provides MySQL and MariaDB support for the Flyway database migration engine. It implements database-specific functionality including SQL parsing, connection handling, schema operations, and transaction management tailored for MySQL environments.
pom.xml or Gradle build.gradleMaven:
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-mysql</artifactId>
<version>11.8.2</version>
</dependency>Gradle:
implementation 'org.flywaydb:flyway-mysql:11.8.2'The plugin is automatically discovered through Java's Service Provider Interface (SPI). No direct imports are needed for basic usage as Flyway automatically loads the plugins.
For direct access to specific classes:
import org.flywaydb.database.mysql.MySQLDatabaseType;
import org.flywaydb.database.mysql.mariadb.MariaDBDatabaseType;
import org.flywaydb.database.mysql.MySQLDatabase;
import org.flywaydb.database.mysql.MySQLConnection;
import org.flywaydb.database.mysql.MySQLParser;
import org.flywaydb.database.mysql.MySQLSchema;
import org.flywaydb.database.mysql.MySQLTable;
import org.flywaydb.database.mysql.MySQLNamedLockTemplate;
import org.flywaydb.authentication.mysql.MySQLOptionFileReader;The plugin is used automatically by Flyway when connecting to MySQL or MariaDB databases. Simply configure Flyway with MySQL connection details:
import org.flywaydb.core.Flyway;
// Configure Flyway - the MySQL plugin is auto-discovered
Flyway flyway = Flyway.configure()
.dataSource("jdbc:mysql://localhost:3306/mydb", "user", "password")
.load();
// Run migrations - MySQL plugin handles database-specific operations
flyway.migrate();Supported JDBC URLs:
jdbc:mysql://... - Standard MySQLjdbc:mariadb://... - MariaDBjdbc:google://... - Google Cloud SQLjdbc:p6spy:mysql://... - P6Spy proxy URLsThe flyway-mysql plugin is built around Flyway's extensible database type system:
MySQLDatabaseType and MariaDBDatabaseType register as Flyway plugins via SPIMySQLDatabase and MariaDBDatabase provide database-specific behaviorMySQLConnection handles MySQL-specific connection state and operationsMySQLParser and MariaDBParser handle MySQL/MariaDB-specific SQL syntaxMySQLSchema and MySQLTable manage database schema objectsMySQLOptionFileReader supports MySQL option file authenticationPrimary entry points for MySQL and MariaDB database support, automatically discovered by Flyway's plugin system.
public class MySQLDatabaseType extends BaseDatabaseType {
public String getName();
public List<String> getSupportedEngines();
public boolean handlesJDBCUrl(String url);
public String getDriverClass(String url, ClassLoader classLoader);
public Database createDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor);
public Parser createParser(Configuration configuration, ResourceProvider resourceProvider, ParsingContext parsingContext);
}
public class MariaDBDatabaseType extends BaseDatabaseType {
public String getName();
public int getPriority();
public boolean handlesJDBCUrl(String url);
public String getDriverClass(String url, ClassLoader classLoader);
public Database createDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor);
public Parser createParser(Configuration configuration, ResourceProvider resourceProvider, ParsingContext parsingContext);
}MySQL-specific database implementations providing connection management, version detection, and specialized behavior for MySQL environments.
public class MySQLDatabase extends Database<MySQLConnection> {
public MySQLDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor);
public boolean isWsrepOn();
public static MigrationVersion extractMySQLVersionFromString(String selectVersionOutput);
public static MigrationVersion extractMariaDBVersionFromString(String selectVersionOutput);
public static boolean isRunningInPerconaXtraDBClusterWithStrictMode(JdbcTemplate jdbcTemplate);
public static boolean isWsrepOn(JdbcTemplate jdbcTemplate);
public static boolean isRunningInGTIDConsistencyMode(JdbcTemplate jdbcTemplate);
}
public class MariaDBDatabase extends MySQLDatabase {
public MariaDBDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor);
}MySQL-specific connection handling with state restoration, AWS RDS detection, and variable management.
public class MySQLConnection extends Connection<MySQLDatabase> {
public MySQLConnection(MySQLDatabase database, java.sql.Connection connection);
public boolean isAwsRds();
}MySQL and MariaDB-specific SQL parsers handling database-specific syntax, delimiters, and statement types.
public class MySQLParser extends Parser {
public MySQLParser(Configuration configuration, ParsingContext parsingContext);
}
public class MariaDBParser extends MySQLParser {
public MariaDBParser(Configuration configuration, ParsingContext parsingContext);
}MySQL-specific implementations for schema and table operations with database-specific behavior.
class MySQLSchema extends Schema<MySQLDatabase, MySQLTable> {
MySQLSchema(JdbcTemplate jdbcTemplate, MySQLDatabase database, String name);
public Table getTable(String tableName);
}
class MySQLTable extends Table<MySQLDatabase, MySQLSchema> {
MySQLTable(JdbcTemplate jdbcTemplate, MySQLDatabase database, MySQLSchema schema, String name);
}Additional utility classes for named locks and authentication support.
public class MySQLNamedLockTemplate {
MySQLNamedLockTemplate(JdbcTemplate jdbcTemplate, int discriminator);
public <T> T execute(Callable<T> callable);
}
public class MySQLOptionFileReader implements ExternalAuthFileReader {
public MySQLOptionFileReader();
public List<String> getAllContents();
public void populateOptionFiles();
}// Database configuration and connection types
public interface Configuration {
// Flyway configuration interface
}
public interface JdbcConnectionFactory {
// JDBC connection factory interface
}
public interface StatementInterceptor {
// Statement interception interface
}
// Migration and version types
public class MigrationVersion {
public static MigrationVersion fromVersion(String version);
public boolean isAtLeast(String targetVersion);
}
// Template and execution types
public interface Callable<T> {
T call() throws Exception;
}public class FlywayException extends RuntimeException {
// General Flyway exceptions
}
public class FlywaySqlException extends FlywayException {
// SQL-related exceptions
}
public class FlywayEditionUpgradeRequiredException extends FlywayException {
// Premium feature exceptions
}public interface ExternalAuthFileReader {
List<String> getAllContents();
}