In Slick is there a way to declar Tables without u

2019-08-02 07:10发布

In my persistence code all through out the tables, etc. I have the following import

import scala.slick.driver.PostgresDriver.simple._

This is nice because it works, but this is a problem because all my code is bound to Postgres exclusively. If I want my production to do Postgres and my test to be HSQLDB, for example, I can't. I'd like to declare which DataSource/Driver when I'm running my persistence manager (which will do the create) instead of at the table declaration. What am I missing?

2条回答
地球回转人心会变
2楼-- · 2019-08-02 07:23

This is certainly possible using the cake pattern. My team uses H2 in development and MySQL in production.

See MultiDBExample and MultiDBCakeExample in https://github.com/slick/slick-examples

查看更多
来,给爷笑一个
3楼-- · 2019-08-02 07:36

As far as I was able to find, I think this is a definite restriction in Slick. So much so that I dropped my test environments database and switched it to the same type as my production one. In retrospect, this is what I should have been doing in the first place, but I do understand this is sometimes easier said than done.

查看更多
登录 后发表回答