How to mark a database in an inconsistent state as allowed in production with Play

I am using Scala Play version 2.3.1 with the following environments

  • Development on a laptop
  • Test with Heroku deployment
  • Live with Heroku Deployment

I am making changes to the database structure using evolution. It was a little tricky, involving dropping indexes and adding others. This is evolution 5. Test and life are currently in the evolutionary stage.

If I blow down the database on my development machine, the application works as expected. If I deploy for testing, I get an "Application Error" when accessing any web page

In the logs I get:

play - execute with -DapplyEvolutions.default = true and -DapplyDownEvolutions.default = true if you want to run them automatically, including dips (be careful, especially if your evolution is discarding existing data) The default database needs evolution! Sorry, the server cannot start.

I do have -DapplyEvolutions.default = true, but I don't have any allowed ones (they are destructive and I don't want to execute them) When I go to the database via Sql Squirrel I find

  • 5 lines
  • Each column "apply_at" has data in it (including line 5)
  • Each column state has a 'apply' value in it

I researched the database and evolution 5 was applied.

So, if I were working in development mode, I would probably set the underlying database to be inconsistent by default. I would click the "Mark it" button and I could continue

How do I do this when running in "production mode"?

+3


source to share


1 answer


I got this answer from Google Group Play-Framework

Unfortunately, you cannot "mark the database as allowed" if you run the application in Prod mode. I think this is a Play issue, can you please report this ( http://github.com/playframework/playframework/issues )?

To solve your problem, you can run the application in Dev mode (using sbt run

) and then click a button in your web browser, or manually update the play_evolutions table to mark your conflicts as resolved (here's how to do it in Play: https: // github.com/playframework/playframework/blob/master/framework/src/play-jdbc/src/main/scala/play/api/db/evolutions/EvolutionsApi.scala#L297-L311 ).

There was a problem, I did 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 did not explain all my symptoms: but I could easily have two questions. For example, when I looked at the play_evolution table, there was no "apply_up" or "apply_down". However, it certainly "resolved" this part of the problem and helped me a little to understand what was going on.

+2


source







All Articles