Flyway: Version 6.2.3: Parsing issue with CREATE TABLE IF EXISTS

Created on 17 Feb 2020  路  3Comments  路  Source: flyway/flyway

Which version and edition of Flyway are you using?

6.2.3 Community

If this is not the latest version, can you reproduce the issue with the latest one as well?

(Many bugs are fixed in newer releases and upgrading will often resolve the issue)
Works fine in 6.2.2

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Java API

Which database are you using (type & version)?

MySQL/Aurora (MySQL in dev/Aurora in staging, both have issue)

Which operating system are you using?

macOS Catalina in dev, Alpine in staging - both have issue

What did you do?

(Please include the content causing the issue, any relevant configuration settings, the SQL statement that failed (if relevant) and the command you ran.)
Trying to run a migration with CREATE TABLE IF EXISTS statement

What did you expect to see?

Expected table to be created

What did you see instead?

Exception thrown when running migrations:
org.flywaydb.core.api.FlywayException: Unable to parse statement in db/migration/...sql at line 1 col 1: Incomplete statement at line 1 col 1: CREATE TABLE IF NOT EXISTS

MySQL fixed bug

Most helpful comment

Duplicate of https://github.com/flyway/flyway/issues/2675

This regression has been fixed, and will be released in 6.2.4, later this week.

I'll leave this open for now to collate other duplicate reports into one issue.

All 3 comments

Duplicate of https://github.com/flyway/flyway/issues/2675

This regression has been fixed, and will be released in 6.2.4, later this week.

I'll leave this open for now to collate other duplicate reports into one issue.

Another example that fails with 6.2.3, works with 6.2.2 and with mysql client/cli.

State: HY000 - Error Code: 1681)
ERROR: Unable to parse statement in db/flyway/sql/V005__add_adjacency_team.sql at line 9 col 1: Incomplete statement at line 9 col 1: set @query = IF(@exist <= 0,
'ALTER TABLE `teams` ADD COLUMN `parent_team_id` int(10) unsigned DEFAULT NULL AFTER `type`;',
'select \'Column Exists\' status');
prepare stmt from @query;
EXECUTE stmt;

Full script is :

SELECT count(*)
INTO @exist
FROM information_schema.columns
WHERE table_schema = database()
and COLUMN_NAME = 'parent_team_id'
AND table_name = 'teams';

set @query = IF(@exist <= 0,
'ALTER TABLE `teams` ADD COLUMN `parent_team_id` int(10) unsigned DEFAULT NULL AFTER `type`;',
'select \'Column Exists\' status');

prepare stmt from @query;

EXECUTE stmt;

@lakamsani That should also be fixed in 6.2.4

Was this page helpful?
0 / 5 - 0 ratings