[2.3-scala] How do I mark a database in a inconsistent state as resolved in production with Play

865 views
Skip to first unread message

Phil Rice

unread,
Dec 30, 2014, 8:57:15 AM12/30/14
to play-fr...@googlegroups.com
I am using Scala Play version 2.3.1 with the following environments

 - Development on a Laptop  
 - Test with a Heroku deployment 
 - Live with a  Heroku deployment

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 and look at the play-evolutions table I find the following

 - 5 rows 
 - Each column 'applied_at' has a date in it (including row 5)
 - Each column 'state' has the value 'applied' in it

I have investigated the database and evolution 5 has been applied. All the changes that evolution 5 requires are done.

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'?

Pedro Antonio Hidalgo Guzmán

unread,
Jan 1, 2015, 8:03:05 PM1/1/15
to play-fr...@googlegroups.com
Hi, 

I prefer not to use evolutions in the production environment. I update the production DB manually, but obviously I test the sql script in dev mod. For me this is a more secure way to do things.

Phil Rice

unread,
Jan 5, 2015, 2:51:08 AM1/5/15
to play-fr...@googlegroups.com
Thank you Pedro

Unfortunately I am in the position of having got a build with evolutions in it.  And all I need to do is 'mark the database as resolved'. But I have no idea how to do that. 

Surely there are some people in this group that use evolutions: This must be a fairly common need...

At the moment I am in the position of having a working system that I cannot run without blowing away the database. I would really like not to have blow away the database! 

If the recommended solution is 'don't use evolutions' then why does Play have evolutions in the first place? If there recommended solution is 'use evolutions' then how do I do the activity that is really easy in Dev, in the Production environment?

--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/kfciWoHPL1Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Stuff our lawyer makes us say: 
* This isn't a contract, it's just a chat
* This is confidential:  If you get this, and you shouldn't, please tell me

Julien Richard-Foy

unread,
Jan 5, 2015, 2:57:10 AM1/5/15
to play-fr...@googlegroups.com
Hi,

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).


--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
  Z E N G U L A R I T Y
––––––––––––––––––––––
Julien RICHARD-FOY - Programmer

56 rue Saint Lazare 75009 Paris
625 Market Street - San Francisco

Phil Rice

unread,
Jan 5, 2015, 3:02:27 AM1/5/15
to play-fr...@googlegroups.com
That's very helpful, thank you. I will file an issue about it.

I'm about to spend several hours (guess) now messing around working out how to do this in Heroku. The problem with magically helpful containers I guess is that at some point you have to open up the magic, and try and work out how they work. Does anyone have any experience in doing this on Heroku that might help with it? 
Reply all
Reply to author
Forward
0 new messages