Create MySQL schema with gradle and flyway plugin Create MySQL schema with gradle and flyway plugin jenkins jenkins

Create MySQL schema with gradle and flyway plugin


I followed Get started with Gradle and Flyway and everything ran ok.

I am using gradle 2.2 and the build.gradle file is:

buildscript {    repositories {        mavenCentral()    }    dependencies {        classpath 'mysql:mysql-connector-java:5.1.34'        classpath 'org.flywaydb:flyway-gradle-plugin:3.1'    }}apply plugin: 'flyway'apply plugin: 'java'flyway {    url = 'jdbc:mysql://localhost:3306'    user = 'root'    password = 'root'    schemas = ['demo1']}

After that, run gradle flywayMigrate -i. If the database does not exist, will be created by flyway.

You can see a list of Flyway tasks here: link


There is a subtle, but important difference between what you have there and what Flyway can do: since version 2.1 Flyway can create schemas, but not databases.

The name in the MySQL url is a database you must create yourself using the MySQL command create database. Within that database, Flyway can create the schemas you specify with flyway.schemas.