Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 6.2.3: Parsing issue with CREATE TABLE IF EXISTS #2676

Closed
jcputney opened this issue Feb 17, 2020 · 3 comments
Closed

Version 6.2.3: Parsing issue with CREATE TABLE IF EXISTS #2676

jcputney opened this issue Feb 17, 2020 · 3 comments

Comments

@jcputney
Copy link

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

@Lyeeedar Lyeeedar added this to the Flyway 6.2.4 milestone Feb 17, 2020
@Lyeeedar
Copy link
Contributor

Duplicate of #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.

@lakamsani
Copy link

lakamsani commented Feb 18, 2020

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;

@Lyeeedar Lyeeedar self-assigned this Feb 19, 2020
@Lyeeedar
Copy link
Contributor

Lyeeedar commented Feb 19, 2020

@lakamsani That should also be fixed in 6.2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants