Play + Ebean: Changes to the model + database
-
02-01-2020 - |
Question
I'm currently using Java Play
and persisting models through Ebean
to MySQL
. This is going to be a generic question – what I see is that whenever I make changes to a model – sometimes just adding a property, after applying the evolution script, the existing data in the corresponding table gets truncated.
Since I love play and I'm thinking about deploying my next project using Play, this is an important question for me – is there a workaround to securely make model changes? Or is the behaviour I'm seeing only when running the application in development mode?
I can't find much about this subject elsewhere.
Solution
That's common approach of Ebean - it doesn't truncate your tables it just drops whole DB and recreates it with new DDL: @see answer to the other question for explanation.
Note: In meantime I found that using standalone approach which is MyBatis Migrations is little bit more comfortable then Play's evolutions, anyway you need still to create the migrations manually (as evolutions).