playframework - how to automatically increment evo

2019-06-03 06:44发布

问题:

So I'm using playframework 2.0 and my application is ready for release. as I have been developing I have noticed that: conf\evolutions\default\1.sql has been automatically changing each time I add/modify my model layer. As I am about to release my application I was wondering how do I set this to start adding it to 2.sql instead of 1? I would like to tag/branch the revision so that if I need to upgrade my release in the future the system will notice that it has 1.sql installed so it will only need to run 2.sql.

I am currently using a JDBC databse, and noticed that during development if I made any changes it would update 1.sql and then the next time I ran the application it would wipe all my data clean.

So how do I make it so evolution 1 is finished?

I currently have the config option: applyEvolutions.default=true

is this a bad idea for release?

Thanks for the help

回答1:

It's definitely bad idea

Ebean doesn't create ALTERS but CREATE version of DDLs, so in case you'll modify any model and will send it to the production it will DROP all tables and recreate them. Of course all data will be lost.

Therefore you need to remove two first lines from the 1.sql to disable modyfying the file by Ebean.

From now you'll need create files like 2.sql and next manually. In these new files you need to add only modifying statement.