Reputation: 2098
I am using Scala Play version 2.3.1 with the following environments
I am making a change to the database structure using evolutions. It was a little complicated involving the removal of indexes and the adding of others. This is evolution 5. Test and live are currently on evolution 4.
If I blow away the database on my development machine, the application works as expected. If I deploy to test I get 'Application Error' when I access any web page
In the logs I get:
play - Run with -DapplyEvolutions.default=true and -DapplyDownEvolutions.default=true if you want to run them automatically, including downs (be careful, especially if your down evolutions drop existing data) Database 'default' needs evolution! Oops, cannot start the server.
I do actually have -DapplyEvolutions.default=true set, but I don't have the 'downs' enabled (They are destructive and I don't want to execute them) When I go to the database via Sql Squirrel I find the following
I have investigated the database and evolution 5 has been applied.
So if I was running in development mode, I would probably get the web page 'database default is in an inconsistent state'. I would click the 'Mark it resolved' button, and I could continue
How do I do this when running in 'production mode'?
Upvotes: 3
Views: 2122
Reputation: 2098
I received this answer from the Google Group Play-Framework
Unfortunately you can not “mark the database as resolved” if you run the application in Prod mode. I think this is a problem in Play, can you please file an issue about that (http://github.com/playframework/playframework/issues)?
To solve your problem, you can either run the application in Dev mode (using
sbt run
) and then click on the button from your web browser, or manually update the play_evolutions table to mark your conflicts as resolved (here is how it is done by Play: https://github.com/playframework/playframework/blob/master/framework/src/play-jdbc/src/main/scala/play/api/db/evolutions/EvolutionsApi.scala#L297-L311).
Having raised the issue, I executed the following manually
update play_evolutions set state = 'applied' where state = 'applying_up' and id = " + revision
delete from play_evolutions where state = 'applying_down' and id = " + revision
This didn't explain all my symptoms: but I could easily of had two issues. For example when I looked at the play_evolution table there were no 'applying_up' or 'applying_down'. However this has certainly 'resolved' this part of the problem, and helped quite a bit with my understanding of what was happening
Upvotes: 2