Mysql dump comments directives and simple comments

2019-09-05 04:28发布

问题:

We are planing to use Flyway to manage our migrations because it seams to be a great tool that could perfectly suit our needs. What we have today is MySQL databases for development, and mysql - oracle DB for production cycle.

It seems impossible today with Flyway integrated with ant to deal with simple comments that are into mysqldump comments directives. It looks like this :

/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `lockObject`(
    IN parTypeId INTEGER,
    IN parObjectId INTEGER,
    IN parUserId INTEGER,
    IN parLockTime INTEGER,
    OUT parSuccess BOOLEAN,
    OUT parLockedOn INTEGER, /* time is elapsing from the beginning */
    OUT parErrUserId INTEGER)
BEGIN

    #proc declaration

END */;;

A Flyway migration return the following error

com.googlecode.flyway.core.api.FlywayException: Error executing statement at line 10807:    OUT parErrUserId INTEGER)
BEGIN
    DECLARE locTableName CHAR(50)
Caused by com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OUT parErrUserId INTEGER)

Is there somewhere something I missed that could permit to deal with this "comment" imbrication issue ?

Regards

回答1:

Put the comments on a new line and you should be good to go. Flyway's parser currently has trouble dealing with end of line comments and multiple statements per line.

I am plan on addressing this in time for 2.2. Until then, please use this workaround.