1
votes

I just added an SQL file to create a new table in my database to my evolution scripts. Accidentally, I had a typo in my SQL script. I then started my Play webapp via activator with config setting applyEvolutions.default=true. Consequently, when I run my webapp, it complains due to a SQL syntax error and inconsistent database.

I corrected the syntax error, but somehow Play/Evolutions/Activator does not consider my corrections. It still wants to execute the wrong and uncorrected version of my SQL script. This is obvious since it cites my syntax error from the uncorrected version. How can I make Play accept my corrected SQL script?

Additionally, Play states the following error message:

play.api.db.evolutions.InconsistentDatabase: 
Database 'default' is in an inconsistent state!
[An evolution has not been applied properly.

I use very recent Play, Evolution and MySQL versions.

1
If you are a beginner, simplify your work and do not use evolution. Just update your db model and go one in coding. Just like this.asch
I just wonder that such an elementary operation won't be possible?Gerhard Hagerer
You probably need to follow these steps: 1) Mark the database error as manually fixed (when you try to navigate to your app, there will be a button to enable you to do that) 2) Fix the script while paying attention to the DOWNS section too and 3) Try to start the app again with the corrected script.marcospereira

1 Answers

2
votes

I found out that the answer to my question is already there in the official documentation:

Run the fixed SQL command on your database and then mark this problem as manually resolved by clicking on the button.

But because your evolution script has errors, you probably want to fix it. So you modify the sql evolutions script.

Play detects this new evolution that replaces the previous one, and will run the appropriate script. Now everything is fixed, and you can continue to work.

https://www.playframework.com/documentation/2.5.x/Evolutions#inconsistent-states