我为我的spring boot应用程序从flyway5.0.7升级到5.1.4,然后尝试运行单元测试,但在db迁移步骤失败。
我的flyway脚本包含以“-”开头的单行注解,但后面没有空格。
--Hello
CREATE TABLE `products` (
`product_code` VARCHAR(10) NOT NULL,
`product_type` VARCHAR(1) NOT NULL,
PRIMARY KEY (`product_code`));
我希望db迁移能够成功,就像在5.0.7中一样。
然而,它却出现了下面的错误。
Caused by: org.flywaydb.core.internal.sqlscript.FlywaySqlScriptException:
Migration V1__create_products.sql failed
----------------------------------------
SQL State : 42000
Error Code : 1064
Message : 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 '--Hello
CREATE TABLE `products` (
`product_code` VARCHAR(10) NOT NULL,
`prod' at line 1
Location : db/migration/V1__create_products.sql (/Users/wai_loon/IdeaProjects/deposits/target/classes/db/migration/V1__create_products.sql)
Line : 1
Statement : --Hello
CREATE TABLE `products` (
`product_code` VARCHAR(10) NOT NULL,
`product_type` VARCHAR(1) NOT NULL,
PRIMARY KEY (`product_code`))
at org.flywaydb.core.internal.database.ExecutableSqlScript.handleException(ExecutableSqlScript.java:331)
at org.flywaydb.core.internal.database.ExecutableSqlScript.executeStatement(ExecutableSqlScript.java:301)
at org.flywaydb.core.internal.database.ExecutableSqlScript.execute(ExecutableSqlScript.java:243)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.execute(SqlMigrationExecutor.java:91)
at org.flywaydb.core.internal.command.DbMigrate.doMigrateGroup(DbMigrate.java:352)
... 59 more
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 '--Hello
CREATE TABLE `products` (
`product_code` VARCHAR(10) NOT NULL,
`prod' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.Util.getInstance(Util.java:408)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2482)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2440)
at com.mysql.jdbc.StatementImpl.executeInternal(StatementImpl.java:845)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:745)
at org.flywaydb.core.internal.util.jdbc.JdbcTemplate.executeStatement(JdbcTemplate.java:244)
at org.flywaydb.core.internal.database.StandardSqlStatement.execute(StandardSqlStatement.java:44)
at org.flywaydb.core.internal.database.ExecutableSqlScript.executeStatement(ExecutableSqlScript.java:280)
... 62 more
--
注意:在flyway github上也发布了这个问题,https://github.com/flyway/flyway/issues/2081.
暂无答案!
目前还没有任何答案,快来回答吧!