Git Product home page Git Product logo

gradle-flyway-plugin's People

Contributors

alkamo avatar ben-manes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gradle-flyway-plugin's Issues

MySQLSyntaxErrorException for scripts with BIT default values

When I try to run SQL-scripts for MySQL that contains creation of two or more tables with default values for the BIT datatype (for example b'0') I get an error when I run them via your flyway plugin. If I use the similar plugin by Katta, or run the sqript directly it works fine. I do not know if this is a bug in the flyway plugin or the underlying dependency com.googlecode.flyway. But here is how to reproduce it. I run the following gradle script with gradle 1.6:

apply plugin: 'flyway'
apply plugin: 'java'

flyway {
    databases {
        main {
            url = "jdbc:mysql://127.0.0.1/my_db"
            driver = 'com.mysql.jdbc.Driver'
            user = 'root'
            initVersion = 0
            locations = [ 'filesystem:src/sql/migrate' ]
        }
    }
}

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'mysql:mysql-connector-java:5.1.22'
        classpath 'com.github.ben-manes:gradle-flyway-plugin:0.6'
    }
}

In the migrate directory I have one file named V1__tables.sql that contains the following SQL:

CREATE  TABLE IF NOT EXISTS `my_table1`
    (`my_bit1` BIT(1) NOT NULL DEFAULT b'0')
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

CREATE  TABLE IF NOT EXISTS `my_table2`
    (`my_bit2` BIT(1) NOT NULL DEFAULT b'0')
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

If I run this I get the exeption "com.googlecode.flyway.core.api.FlywayException: Error executing statement at line 1. [...] Caused by com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax;"

If I remove the last table creation it will start to work. Or if I change the script to not use BIT default values but INTEGER default values like this:

CREATE  TABLE IF NOT EXISTS `my_table1`
    (`my_bit1` BIT(1) NOT NULL DEFAULT 0)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

CREATE  TABLE IF NOT EXISTS `my_table2` 
    (`my_bit2` BIT(1) NOT NULL DEFAULT 0)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

FlywayException: Unable to determine URL for classpath location: db/migration

I tried to configure Flyway in my project using your plugin and got following error:

(...)
Caused by: com.googlecode.flyway.core.api.FlywayException: Unable to determine URL for classpath location: db/migration (ClassLoader: org.gradle.util.MutableURLClassLoader@3efe45d3)
    at com.googlecode.flyway.core.util.scanner.classpath.ClassPathScanner.getLocationUrlsForPath(ClassPathScanner.java:179)
    at com.googlecode.flyway.core.util.scanner.classpath.ClassPathScanner.findResourceNames(ClassPathScanner.java:135)
    at com.googlecode.flyway.core.util.scanner.classpath.ClassPathScanner.scanForResources(ClassPathScanner.java:60)
    at com.googlecode.flyway.core.resolver.sql.SqlMigrationResolver.resolveMigrations(SqlMigrationResolver.java:90)
    at com.googlecode.flyway.core.resolver.CompositeMigrationResolver.collectMigrations(CompositeMigrationResolver.java:158)
    at com.googlecode.flyway.core.resolver.CompositeMigrationResolver.doFindAvailableMigrations(CompositeMigrationResolver.java:140)
    at com.googlecode.flyway.core.resolver.CompositeMigrationResolver.resolveMigrations(CompositeMigrationResolver.java:112)
    at com.googlecode.flyway.core.info.MigrationInfoServiceImpl.refresh(MigrationInfoServiceImpl.java:87)
    at com.googlecode.flyway.core.command.DbMigrate$1.doInTransaction(DbMigrate.java:144)
    at com.googlecode.flyway.core.command.DbMigrate$1.doInTransaction(DbMigrate.java:138)
    at com.googlecode.flyway.core.util.jdbc.TransactionTemplate.execute(TransactionTemplate.java:54)
    at com.googlecode.flyway.core.command.DbMigrate.migrate(DbMigrate.java:137)
(...)

After some debugging I'm not sure why this happens (thing is about class loaders and sun.misc.CompoundEnumeration class which behave in that case not exactly as I would suppose), but was able to find a workaround (which allow me to use Flyway with Gradle) and modify your example project to reproduce the issue which hopefully allows you to find a reason and fix it (or forward it to Axel, Gradle guys or Oracle respectively ;) ).

Type: ../gradlew flywayInfo to reproduce it with the example in my branch.

FlywayException: Unable to determine URL for classpath location: db/migration

I've added maven dependency for flyway 3.0 to my test console application and couldn't run migration neither from maven plugin nor from spring context.

plugin configuration is: 
            <plugin>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.27</version>
                    </dependency>
                    <dependency>
                        <groupId>org.flywaydb</groupId>
                        <artifactId>flyway-core</artifactId>
                        <version>3.0</version>
                    </dependency>
                </dependencies>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <url>jdbc:mysql://localhost/addressbook?useUnicode=yes&amp;characterEncoding=UTF-8</url>
                    <driver>com.mysql.jdbc.Driver</driver>
                    <user>root</user>
                    <password>root</password>
                    <schemas>
                        <schema>addressbook</schema>
                    </schemas>
                </configuration>

At first I build my project:

mvn clean package

then run flyway maven plugin:

mvn compile flyway:migrate

The maven output log is :

[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:3.0:migrate (compile) on project addressbook: org.flywaydb.core.api.FlywayException: Unable to scan for SQL migrations in location: classpath:db/migration: Unable to determine URL for classpath location: db/migration (ClassLoader: ClassRealm[plugin>org.flywaydb:flyway-maven-plugin:3.0, parent: sun.misc.Launcher$AppClassLoader@530f243b])

Into web application flyway migration works fine both on 3.0 and 2.3.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.