问题
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