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

Trigger Delimiter Problem #2666

Closed
marcobehler opened this issue Feb 6, 2020 · 2 comments
Closed

Trigger Delimiter Problem #2666

marcobehler opened this issue Feb 6, 2020 · 2 comments
Assignees
Milestone

Comments

@marcobehler
Copy link

@marcobehler marcobehler commented Feb 6, 2020

Hi guys,
I do not know if there is a simple way around it, but I am running into a bug when using MySQL and Flyway. Version doesn't really matter, but I tried it with MySQL5-8 as well as Flyway 6.2.1.

CREATE TRIGGER before_insert_users BEFORE INSERT ON USERS FOR EACH ROW IF new.api_key IS NULL THEN SET new.api_key = uuid(); END IF;

The issue is that Flyway parses in the statement but thinks the ";" after uuid() is the end of the statement, hence cutting of the END IF and hence you cannot apply that migration succesfully.

Is there an easy way to change delimiters in these cases or is this a bug?

Thanks
Marco

@MikielAgutu MikielAgutu added this to the Flyway 6.x milestone Feb 7, 2020
@MikielAgutu
Copy link
Contributor

@MikielAgutu MikielAgutu commented Feb 7, 2020

Looks like this is a bug. There's no way to change the delimiters, it's something we need to fix on our end.

@MikielAgutu MikielAgutu removed this from the Flyway 6.x milestone Feb 7, 2020
@MikielAgutu MikielAgutu added this to the Flyway 6.2.3 milestone Feb 7, 2020
@Lyeeedar Lyeeedar self-assigned this Feb 7, 2020
@MikielAgutu
Copy link
Contributor

@MikielAgutu MikielAgutu commented Feb 7, 2020

After more investigation we've actually found a workaround using the MySql DELIMITER option. The parser seems to be happy with things like:

DELIMITER #
CREATE TRIGGER before_insert_users BEFORE INSERT ON USERS FOR EACH ROW IF new.api_key IS NULL THEN SET new.api_key = uuid(); END IF#
DELIMITER ;

Nonetheless we should still fix it.

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