How to avoid creating schema with PlayFramework

无人久伴 提交于 2019-12-14 02:51:17

问题


I have an existing database schema managed by another webapp. The playframework I am creating needs to read/write to this existing schema but it's deleting and recreating the tables when play starts up.

How do I turn off the table creation?

update:

  • play 1.2.5
  • mysql

update2:

@Entity(name="mytable_name")
public class Sample extends Model {    
   public Integer some_value;
   public String fullname;
}

inside a Controller method...

List<Sample> list = Sample.findAll();

The table exists with data, I run "play test", hit the controller method that calls findAll, and the table is dropped, recreated, and now empty.

The schemas do not match perfectly in data types with text fields being different sizes. I was expecting query errors but not this.


回答1:


If you are using Play 1.x with JPA you can put this line in your application.conf

jpa.ddl=none



回答2:


From official evolutions' documentation:

Evolutions are automatically activated if a database is configured in application.conf and evolution scripts are present. You can disable them by setting evolutions.enabled to false. For example when tests set up their own database you can disable evolutions for the test environment.



来源:https://stackoverflow.com/questions/11626004/how-to-avoid-creating-schema-with-playframework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!