0
votes

I'm trying to set up a project using play framework 2.7.0, now I'm trying to connect to MySQL database using sbt-play-ebean 5.0.0.

Here is my code. https://github.com/hiroya8649/play-mysql-ebean-test

Here are the files you may want to check:

https://github.com/hiroya8649/play-mysql-ebean-test/blob/master/conf/application.conf

https://github.com/hiroya8649/play-mysql-ebean-test/blob/master/build.sbt

https://github.com/hiroya8649/play-mysql-ebean-test/blob/master/project/plugins.sbt

Now I try to connect to localhost:9000, it tells me Database 'default' needs evolution! An SQL script will be run on your database and a run this script button.

It's the same with this script: https://github.com/hiroya8649/play-mysql-ebean-test/blob/master/conf/evolutions/default/1.sql But if I click run this script it will tell me

Evolution has not been applied properly. Please check the problem and resolve it manually before marking it as resolved. -
We got the following error: 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 'delimiter $$ -- -- PROCEDURE: usp_ebean_drop_foreign_keys TABLE, COLUMN -- delete' at line 1 [ERROR:1064, SQLSTATE:42000], while trying to run this SQL script:

If I just mark it resolved, the play hello world page will show. But I don't think it's correct, and I have added a Task model in the project so I think it should be created as a table in the database but it doesn't.

Is there anything wrong with my settings?


I find the same issue in playframework and play-ebean GitHub, it seems happens from play version 2.6.20 and not been fixed yet.

1

1 Answers

0
votes

You use the wrong delimiter in some cases. Check your code from the command line before adding it to the evolution.

Example:

https://github.com/hiroya8649/play-mysql-ebean-test/blob/master/conf/evolutions/default/1.sql#L10

https://github.com/hiroya8649/play-mysql-ebean-test/blob/master/conf/evolutions/default/1.sql#L40

delimiter $$
....
DROP PROCEDURE IF EXISTS usp_ebean_drop_column;

You need to change to :

DROP PROCEDURE IF EXISTS usp_ebean_drop_column$$

Or:

delimiter $$
...
delimiter ;
DROP PROCEDURE IF EXISTS usp_ebean_drop_column;