We are in the process of deploying a new application using play 2.1.1 to production and are having some real issues with it and the very limited documentation didn't help much...
So it was time to update to a new version, we ran our usual stop/upgrade/start scripts but they failed. For some reason, play was refusing to apply the evolutions. When starting it kept saying
Oops, cannot start the server. @6elnj89fh: Database 'default' needs evolution!
This was even though we tried setting applyEvolutions.default=true
both through command line and in the application_prod.conf file. It also complained that
WARNING! This script contains DOWNS evolutions that are likely destructives
which doesn't make much sense to me since we are going up in version so the downs should not be applied anyway. But it seems this might have been the reason it was refusing to apply the evolutions.
At this point I wasn't so worried as I assumed that there is some manual way to apply evolutions. After extensive searching it looks as though... There was support for this in play 1 but not in play 2. In dev mode you can just press a button in the browser to apply the evolutions but in prod mode I could find NO WAY OF MANUALLY APPLYING EVOLUTIONS. Is this true or did I miss it? I really think this is an important feature! (In hind sight I could have applied the scripts manually and disabled the evolutions plugin but then I would have lost the evolutions tracking which is useful..)
I also wonder how you would go about "backing" your database as I am sure we will get to a point when we need to do that at some point. If there was a manual way to do this it would probably have an optional version argument to downgrade the database. E.g. if you are at version 5 and need to go back to 4 you run play apply-evolutions 4
which would then apply the downs from version 5 and update the evolutions db accordingly. I could apply the downs manually but then again the problem is the evolutions db will once again be in an invalid state...
Getting more desperate I tried all the settings I could find to get the server up again and added the -DapplyDownEvolutions.default=true
option. I assumed this setting would apply downs only when choosing to downgrade the DB (although there seems to be no such option) but what it in fact did was to apply the ups and then instantly apply the downs (I found this out later in troubleshooting as the server now finally started - without any message whatsoever - but gave a cryptic error message when visiting the site). Is that what this setting is supposed to do? If it is I can't understand why the setting even exists. I can't think of any scenario where you would want to apply ups and then instantly downs while migrating to a newer database version. Can someone shed some light on this setting?
At this point I could finally get the app running once again by manually re-running the appropriate "UPs".
At this point we are working on basically re-writing scripts for evolutions handling on our own to have some better control of what is run and to enable going back.. It would be much better to be able to use play functionality for this so I am hoping someone can shed some light on this. If not, maybe this rant can help someone in a similar situation...