or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/maven-org-flywaydb--flyway-mysql

MySQL database type plugin for Flyway database migration engine providing specialized MySQL and MariaDB support for schema migrations.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.flywaydb/flyway-mysql@11.8.x

To install, run

npx @tessl/cli install tessl/maven-org-flywaydb--flyway-mysql@11.8.0

0

# Flyway MySQL

1

2

Flyway 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.

3

4

## Package Information

5

6

- **Package Name**: flyway-mysql

7

- **Package Type**: Maven JAR

8

- **Language**: Java

9

- **Group ID**: org.flywaydb

10

- **Artifact ID**: flyway-mysql

11

- **Version**: 11.8.2

12

- **Installation**: Add dependency to Maven `pom.xml` or Gradle `build.gradle`

13

14

**Maven:**

15

```xml

16

<dependency>

17

<groupId>org.flywaydb</groupId>

18

<artifactId>flyway-mysql</artifactId>

19

<version>11.8.2</version>

20

</dependency>

21

```

22

23

**Gradle:**

24

```gradle

25

implementation 'org.flywaydb:flyway-mysql:11.8.2'

26

```

27

28

## Core Imports

29

30

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.

31

32

For direct access to specific classes:

33

34

```java

35

import org.flywaydb.database.mysql.MySQLDatabaseType;

36

import org.flywaydb.database.mysql.mariadb.MariaDBDatabaseType;

37

import org.flywaydb.database.mysql.MySQLDatabase;

38

import org.flywaydb.database.mysql.MySQLConnection;

39

import org.flywaydb.database.mysql.MySQLParser;

40

import org.flywaydb.database.mysql.MySQLSchema;

41

import org.flywaydb.database.mysql.MySQLTable;

42

import org.flywaydb.database.mysql.MySQLNamedLockTemplate;

43

import org.flywaydb.authentication.mysql.MySQLOptionFileReader;

44

```

45

46

## Basic Usage

47

48

The plugin is used automatically by Flyway when connecting to MySQL or MariaDB databases. Simply configure Flyway with MySQL connection details:

49

50

```java

51

import org.flywaydb.core.Flyway;

52

53

// Configure Flyway - the MySQL plugin is auto-discovered

54

Flyway flyway = Flyway.configure()

55

.dataSource("jdbc:mysql://localhost:3306/mydb", "user", "password")

56

.load();

57

58

// Run migrations - MySQL plugin handles database-specific operations

59

flyway.migrate();

60

```

61

62

**Supported JDBC URLs:**

63

- `jdbc:mysql://...` - Standard MySQL

64

- `jdbc:mariadb://...` - MariaDB

65

- `jdbc:google://...` - Google Cloud SQL

66

- `jdbc:p6spy:mysql://...` - P6Spy proxy URLs

67

- AWS wrapper URLs with MySQL

68

69

## Architecture

70

71

The flyway-mysql plugin is built around Flyway's extensible database type system:

72

73

- **Database Type Plugins**: `MySQLDatabaseType` and `MariaDBDatabaseType` register as Flyway plugins via SPI

74

- **Database Instances**: `MySQLDatabase` and `MariaDBDatabase` provide database-specific behavior

75

- **Connection Management**: `MySQLConnection` handles MySQL-specific connection state and operations

76

- **SQL Parsing**: `MySQLParser` and `MariaDBParser` handle MySQL/MariaDB-specific SQL syntax

77

- **Schema Operations**: `MySQLSchema` and `MySQLTable` manage database schema objects

78

- **Authentication**: `MySQLOptionFileReader` supports MySQL option file authentication

79

80

## Capabilities

81

82

### Database Type Registration

83

84

Primary entry points for MySQL and MariaDB database support, automatically discovered by Flyway's plugin system.

85

86

```java { .api }

87

public class MySQLDatabaseType extends BaseDatabaseType {

88

public String getName();

89

public List<String> getSupportedEngines();

90

public boolean handlesJDBCUrl(String url);

91

public String getDriverClass(String url, ClassLoader classLoader);

92

public Database createDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor);

93

public Parser createParser(Configuration configuration, ResourceProvider resourceProvider, ParsingContext parsingContext);

94

}

95

96

public class MariaDBDatabaseType extends BaseDatabaseType {

97

public String getName();

98

public int getPriority();

99

public boolean handlesJDBCUrl(String url);

100

public String getDriverClass(String url, ClassLoader classLoader);

101

public Database createDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor);

102

public Parser createParser(Configuration configuration, ResourceProvider resourceProvider, ParsingContext parsingContext);

103

}

104

```

105

106

[Database Types](./database-types.md)

107

108

### Database Operations

109

110

MySQL-specific database implementations providing connection management, version detection, and specialized behavior for MySQL environments.

111

112

```java { .api }

113

public class MySQLDatabase extends Database<MySQLConnection> {

114

public MySQLDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor);

115

public boolean isWsrepOn();

116

public static MigrationVersion extractMySQLVersionFromString(String selectVersionOutput);

117

public static MigrationVersion extractMariaDBVersionFromString(String selectVersionOutput);

118

public static boolean isRunningInPerconaXtraDBClusterWithStrictMode(JdbcTemplate jdbcTemplate);

119

public static boolean isWsrepOn(JdbcTemplate jdbcTemplate);

120

public static boolean isRunningInGTIDConsistencyMode(JdbcTemplate jdbcTemplate);

121

}

122

123

public class MariaDBDatabase extends MySQLDatabase {

124

public MariaDBDatabase(Configuration configuration, JdbcConnectionFactory jdbcConnectionFactory, StatementInterceptor statementInterceptor);

125

}

126

```

127

128

[Database Operations](./database-operations.md)

129

130

### Connection Management

131

132

MySQL-specific connection handling with state restoration, AWS RDS detection, and variable management.

133

134

```java { .api }

135

public class MySQLConnection extends Connection<MySQLDatabase> {

136

public MySQLConnection(MySQLDatabase database, java.sql.Connection connection);

137

public boolean isAwsRds();

138

}

139

```

140

141

[Connection Management](./connection-management.md)

142

143

### SQL Parsing

144

145

MySQL and MariaDB-specific SQL parsers handling database-specific syntax, delimiters, and statement types.

146

147

```java { .api }

148

public class MySQLParser extends Parser {

149

public MySQLParser(Configuration configuration, ParsingContext parsingContext);

150

}

151

152

public class MariaDBParser extends MySQLParser {

153

public MariaDBParser(Configuration configuration, ParsingContext parsingContext);

154

}

155

```

156

157

[SQL Parsing](./sql-parsing.md)

158

159

### Schema Management

160

161

MySQL-specific implementations for schema and table operations with database-specific behavior.

162

163

```java { .api }

164

class MySQLSchema extends Schema<MySQLDatabase, MySQLTable> {

165

MySQLSchema(JdbcTemplate jdbcTemplate, MySQLDatabase database, String name);

166

public Table getTable(String tableName);

167

}

168

169

class MySQLTable extends Table<MySQLDatabase, MySQLSchema> {

170

MySQLTable(JdbcTemplate jdbcTemplate, MySQLDatabase database, MySQLSchema schema, String name);

171

}

172

```

173

174

[Schema Management](./schema-management.md)

175

176

### Utility Components

177

178

Additional utility classes for named locks and authentication support.

179

180

```java { .api }

181

public class MySQLNamedLockTemplate {

182

MySQLNamedLockTemplate(JdbcTemplate jdbcTemplate, int discriminator);

183

public <T> T execute(Callable<T> callable);

184

}

185

186

public class MySQLOptionFileReader implements ExternalAuthFileReader {

187

public MySQLOptionFileReader();

188

public List<String> getAllContents();

189

public void populateOptionFiles();

190

}

191

```

192

193

[Utility Components](./utility-components.md)

194

195

## Types

196

197

### Core Types

198

199

```java { .api }

200

// Database configuration and connection types

201

public interface Configuration {

202

// Flyway configuration interface

203

}

204

205

public interface JdbcConnectionFactory {

206

// JDBC connection factory interface

207

}

208

209

public interface StatementInterceptor {

210

// Statement interception interface

211

}

212

213

// Migration and version types

214

public class MigrationVersion {

215

public static MigrationVersion fromVersion(String version);

216

public boolean isAtLeast(String targetVersion);

217

}

218

219

// Template and execution types

220

public interface Callable<T> {

221

T call() throws Exception;

222

}

223

```

224

225

### Exception Types

226

227

```java { .api }

228

public class FlywayException extends RuntimeException {

229

// General Flyway exceptions

230

}

231

232

public class FlywaySqlException extends FlywayException {

233

// SQL-related exceptions

234

}

235

236

public class FlywayEditionUpgradeRequiredException extends FlywayException {

237

// Premium feature exceptions

238

}

239

```

240

241

### Authentication Types

242

243

```java { .api }

244

public interface ExternalAuthFileReader {

245

List<String> getAllContents();

246

}

247

```