Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

Can't execute mysql migration with semicolon in it #38

Closed
phemmer opened this issue Mar 16, 2015 · 2 comments
Closed

Can't execute mysql migration with semicolon in it #38

phemmer opened this issue Mar 16, 2015 · 2 comments

Comments

@phemmer
Copy link

phemmer commented Mar 16, 2015

I am trying to create a migration which adds a trigger to the database. The trigger creation statement contains a semicolon (;). However the mysql migrator splits the input migration file on semicolons, and treats them as separate statements. Because of this I get a syntax error when trying to run the migration.

For example:

create trigger test_insert after insert on test
for each row
begin
    insert into test_event set type='insert', test_id=NEW.id;
end
Error: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4

1: create trigger test_insert after insert on test
2: for each row
3: begin
4:  insert into test_event set type='insert', test_id=NEW.id
@mattes
Copy link
Owner

mattes commented Mar 17, 2015

Please see #1 (comment)

Maybe we should start looking for a good work-around.

@phemmer
Copy link
Author

phemmer commented Mar 17, 2015

Would you be willing to have the mysql driver look for DELIMITER FOO on the first line of each migration, and split on that instead of ;? It would be a bit magicish since the DELIMITER statement isn't actually being parsed by mysql, but it would be valid SQL instead of creating a new syntax just for mattes/migrate.

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

No branches or pull requests

2 participants