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

Migration unable to parse "IF NOT EXISTS" for create table #2866

Closed
ngintherBW opened this issue Jun 30, 2020 · 1 comment
Closed

Migration unable to parse "IF NOT EXISTS" for create table #2866

ngintherBW opened this issue Jun 30, 2020 · 1 comment
Assignees
Milestone

Comments

@ngintherBW
Copy link

ngintherBW commented Jun 30, 2020

Which version and edition of Flyway are you using?

Flyway Community Edition 6.5.0 by Redgate

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)
CE 5.6.0 was the latest available version via Homebrew

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

Command-line version installed via Homebrew on MacOS Catalina 10.15.5

Which database are you using (type & version)?

MariaDB 10.3.22

Which operating system are you using?

MacOS Catalina 10.15.5

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.)
My project has a migration that worked in previous versions of flyway, but when I ran it with the new version of flyway I discovered a parsing issue with the "IF NOT EXISTS" part of the CREATE TABLE statement.

Example of the failed migration:
CREATE TABLE IF NOT EXISTS mydb.example (
firstname varchar(100) NOT NULL,
lastname varchar(50) NOT NULL
)

Example of change that did work:
CREATE TABLE mydb.example (
firstname varchar(100) NOT NULL,
lastname varchar(50) NOT NULL
)

What did you expect to see?

The create table statement should have executed creating the table if it was not present already.

What did you see instead?

flyway migrate
Flyway Community Edition 6.5.0 by Redgate
Database: jdbc:mariadb://localhost:3306/pcsdb (MariaDB 10.4)
Successfully validated 7 migrations (execution time 00:00.032s)
Creating Schema History table pcsdb.flyway_schema_history ...
WARNING: DB: Name 'flyway_schema_history_pk' ignored for PRIMARY key. (SQL State: - Error Code: 1280)
Current version of schema pcsdb: << Empty Schema >>
ERROR: Unable to parse statement in /Users//migrations/V1__Initialize_Database.sql at line 1 col 1. See https://flywaydb.org/documentation/knownparserlimitations for more information: Incomplete statement at line 1 col 1: CREATE TABLE IF NOT EXISTS pcsdb.charges (

@Lyeeedar
Copy link
Contributor

Lyeeedar commented Jul 1, 2020

Thank you for reporting this.

Out of interest, if you add a semicolon to the end of the statement like:

CREATE TABLE IF NOT EXISTS mydb.example (
firstname varchar(100) NOT NULL,
lastname varchar(50) NOT NULL
);

does it parse / execute correctly?

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

3 participants