On play 1.0 when we change a variable type or for example changing from @OneToMany to @ManyToMany in a Model Play was handling the change automatically but with play 2.0 evolution script drop the database. There is any way to make Play 2.0 apply the change without dropping the DB ?
Share
Yes, there is a way. You need to disable automatic re-creation of
1.sqlfile and start to write own evolutions containingALTERSinstead ofCREATES– numbering them with2.sql,3.sqletc.In practice that means, that if you’re working with single database you can also just… manage the database’s tables and columns using your favorite DB GUI. The evolutions are useful only when you can’t use GUI (host doesn’t allow external connections and hasn’t any GUI) or when you are planning to run many instances of the app on the separate databases. Otherwise manual writing the statement will be probably more complicated than using GUI.
Tip: sometimes, if I’m not sure if I added all required relations and constraints into my manual evolutions I’m deleting them (under git controlled folder!) and running the app with Ebean plugin enabled and saving proposed
1.sqlbut I’m NOT applying the changes. Later using git I’m reverting my evolutions and compare with saved auto-generated file andconvertCREATE statements to the ALTERs. There’s no better option for managing changes without using 3-rd part software.