question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FlywayException for incomplete statement if DROP TABLE after comment

See original GitHub issue
Which version and edition of Flyway are you using?

6.2.4 seems to have been specifically introduced at 6.2.4 as 6.2.3 works fine

If this is not the latest version, can you reproduce the issue with the latest one as well?
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Java API

Which database are you using (type & version)?

MySQL 5.7

Which operating system are you using?

Ubuntu Linux

What did you do?

I get an exception when I apply migration script containing:

-- Remove all manual app / mount relationships
DROP TABLE IF EXISTS `tmnManualMountApp`;

It works fine however if there is a (extra) new line after the comment e.g.

-- Remove all manual app / mount relationships

DROP TABLE IF EXISTS `tmnManualMountApp`;

It also works fine for other SQL statements and no new line after comment e.g.

-- Delete corresponding column in mount state
ALTER TABLE `mdmMount`
    DROP COLUMN `status_manual_mode`;
What did you expect to see?

Migration applied without errors

What did you see instead?
Caused by: org.flywaydb.core.api.FlywayException: Unable to parse statement in db/migration/V1_37_0_2__Manual_mode_removal.sql at line 21 col 1: Incomplete statement at line 21 col 1: -- Remove all manual app / mount relationships
DROP TABLE IF EXISTS `tmnManualMountApp`;

at org.flywaydb.core.internal.parser.Parser.getNextStatement(Parser.java:288)
at org.flywaydb.core.internal.parser.Parser.access$000(Parser.java:41)
at org.flywaydb.core.internal.parser.Parser$ParserSqlStatementIterator.next(Parser.java:714)
at org.flywaydb.core.internal.parser.Parser$ParserSqlStatementIterator.next(Parser.java:679)
at org.flywaydb.core.internal.sqlscript.ParserSqlScript.parse(ParserSqlScript.java:82)
at org.flywaydb.core.internal.sqlscript.ParserSqlScript.validate(ParserSqlScript.java:127)
at org.flywaydb.core.internal.sqlscript.ParserSqlScript.executeInTransaction(ParserSqlScript.java:196)
at org.flywaydb.core.internal.resolver.sql.SqlMigrationExecutor.canExecuteInTransaction(SqlMigrationExecutor.java:93)
at org.flywaydb.core.internal.command.DbMigrate.isExecuteGroupInTransaction(DbMigrate.java:312)
at org.flywaydb.core.internal.command.DbMigrate.applyMigrations(DbMigrate.java:275)
at org.flywaydb.core.internal.command.DbMigrate.migrateGroup(DbMigrate.java:244)
at org.flywaydb.core.internal.command.DbMigrate.access$100(DbMigrate.java:54)
at org.flywaydb.core.internal.command.DbMigrate$2.call(DbMigrate.java:162)
at org.flywaydb.core.internal.command.DbMigrate$2.call(DbMigrate.java:159)
at org.flywaydb.core.internal.database.mysql.MySQLNamedLockTemplate.execute(MySQLNamedLockTemplate.java:60)
at org.flywaydb.core.internal.database.mysql.MySQLConnection.lock(MySQLConnection.java:161)
at org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.lock(JdbcTableSchemaHistory.java:139)
at org.flywaydb.core.internal.command.DbMigrate.migrateAll(DbMigrate.java:159)
at org.flywaydb.core.internal.command.DbMigrate.migrate(DbMigrate.java:137)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:193)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:153)
at org.flywaydb.core.Flyway.execute(Flyway.java:521)
at org.flywaydb.core.Flyway.migrate(Flyway.java:153)
at jdk.internal.reflect.GeneratedMethodAccessor244.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1922)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1864)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792)
... 86 common frames omitted

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
djerraballicommented, Feb 27, 2020

experienced the same on 6.2.3 and 6.2.4 with:

create table if not exists `any_table`
0reactions
Lyeeedarcommented, Mar 2, 2020

Should be fixed in commit 569338276d494d8b81b78b5b52cf9d210fc402d8

Read more comments on GitHub >

github_iconTop Results From Across the Web

FlywayException: Incomplete statement - Stack Overflow
This is the complete trace : Caused by: org.flywaydb.core.api.FlywayException: Unable to parse statement in db/migration/V2__procedure.sql ...
Read more >
Release Notes for Flyway Engine - Documentation
When urls are unsupported by check, ascertain which ones are unsupported, and include them as part of the exception. Database compatibility.
Read more >
SQL Server - Flyway by Redgate • Database Migrations Made ...
Flyway's automatic detection for whether SQL statements are valid in transactions does not apply to CREATE/ALTER/DROP statements acting on memory-optimized ...
Read more >
Migrate CockroachDB Schemas with Flyway
This tutorial guides you through a series of simple database schema changes using Flyway, an open-source schema migration tool.
Read more >
DROP TABLE (Transact-SQL) - SQL Server - Microsoft Learn
Syntax for SQL Server and Azure SQL Database DROP TABLE [ IF EXISTS ] { database_name.schema_name.table_name | schema_name.table_name ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found