Multiple database management with Playframework 2.0 and Ebean
-
29-05-2021 - |
Pergunta
I'm on my first experience with Playframework, using 2.0. I'm having troubles configuring two databases to be managed with Eebean ORM (which is integrated into Play). Referring to this documentation page, I came up with:
conf/application.conf
db.global.driver="com.mysql.jdbc.Driver"
db.global.url="mysql://root:root@localhost/phdcoursedb"
# In the developement environment this might even change backend
db.statistics.driver="com.mysql.jdbc.Driver"
db.statistics.url="mysql://root:root@localhost/statistics"
ebean.global="models.global.*"
ebean.statistics="models.statistics.*"
And i wrote the correspondong models in models.globals and models.statistics packages. When I run the application, the evolution system asks me to upgrade (using the file generated by the Ebean DDL). The problem is, for BOTH databases it proposes me an evolution sql script which encapsulates ALL models (both in models.global and in models.statistics).
Thing is, I'd like to keep Ebean DDL on for the second database (I don't actually need it for the other one, which is a legacy untouchable database), but I'd like it to build correct tables only.
Can you see what I'm doing wrong? Actually I didn't deeply explored Ebean documentation, because it always refers to some configuration files which I don't know where to find, as Play! itself embeds Ebean.
Thanks a lot
Davide
Solução
see /framework/src/play/src/main/java/play/db/ebean/EbeanPlugin.java
As I can see in the code if your models list is ended with asterisk it will get all models, so you just need to give a comma separated list of models for each base.