5

In the Play 2.3.x documentation on Evolutions it says

In development mode however it is often simpler to simply trash your development database and reapply all evolutions from the beginning.

However it doesn't give instructions on how to do this. Is there some kind of activator command I can use to do this? How can I reset and reapply evolutions?

Thanks!

Update: I would prefer not to have to mess with my DB manually, but it seems like that's the only way

KJ50
  • 765
  • 1
  • 10
  • 27

2 Answers2

2

If you don't care about the data you have in your database (make sure you don't), you can just drop the database with a sql command (such as "drop database name"). Once you run "play run" again, it should automatically recreate your tables from the sql scripts if you have followed play framework standards since according to the doc:

"Evolutions are automatically activated if a database is configured in application.conf and evolution scripts are present"

Mari
  • 169
  • 11
2

I dont think there is such activator command which would reapply all the evolutions.

An evolutions consist of 2 part Ups and Downs where

  1. The Ups part the describe the required transformations.

  2. The Downs part that describe how to revert them.

    when you apply evolution first time an Ups part is applied and if further you change the schema through entity.It would reapply evolutions in ebean.

If you want to revert create a new dotsql file say 2.sql with Ups part of all drop statements.

By this

In developement mode however it is often simpler to simply trash your developement database and reapply all evolutions from the beginning.

I think they mean to manually drop all the database through your database gui etc.

Also check Similar

Community
  • 1
  • 1
singhakash
  • 7,891
  • 6
  • 31
  • 65
  • 1
    Thanks for the link. I would prefer to not have to manually delete tables from my database, but it seems like that is the only way. – KJ50 Feb 24 '15 at 07:43
  • Dropping the database and re-creating it will be much easier than deleting all tables. – i.am.michiel Feb 24 '15 at 07:47
  • @KJ50 In that case I would prefer JPA over Ebean .In jpa you have option of create or update in `persistence.xml` .You can change accoding to your requirement.And if you don't want to use jpa you have option 2.sql described in my answer.I dont know why or when do you want to create beacause ebean create your schema each time you update it in dotsql file directly or through Entity . Recreating database everytime is not advisory – singhakash Feb 24 '15 at 07:57
  • @singhakash I would prefer to stick with Ebean and not switch to JPA. I suppose option 2 that you mentioned would work. – KJ50 Feb 24 '15 at 08:08