Rolling an evolution back
Asked Answered
W

2

24

This question might seem stupid, but I cannot find any instruction on how to roll back an evolution in Play 2.0. Google only finds pages which say that the "Downs" section of an evolution file is used for that and that's all. Any pointers or instructions will be appreciated.

Whisler answered 9/4, 2012 at 5:19 Comment(2)
Did you see this doc ? playframework.org/documentation/2.0/EvolutionsEnvironment
Yes, I have read it, but it does not say a word about reverting an evolution, using the Downs! section. I might be missing something, but really, the only somewhat remotely relevant topic is touched in the last note paragraph, where it says "In developement mode however it is often simpler to simply trash your developement database and reapply all evolutions from the beginning.". Please tell me if I'm wrong.Whisler
F
24

The Downs part is mainly used to revert an Evolution when the script has changed. That is, you have a project with 2.sql applied to the database and then, due to a merge, 2.sql is modified in the source. Play will run Downs on the old version and then Ups on the new 2.sql to ensure the database is in sync with the codebase.

As far as I know there is no way to trigger Downs by itself, as the purpose of an Evolution is to prepare the database to work with your code, and applying just one Downs step would leave the application in an inconsistent state with many potential errors arising.

If you really need to revert something, that would be a new Evolution (3.sql) where Ups would do the changes required.

Frangipane answered 16/4, 2012 at 11:43 Comment(2)
What is the purpose of # --- !Downs section in evolutions ?Karykaryl
"The Downs part is mainly used to revert an Evolution when the script has changed."Folks
G
6

For play 2.4.x, according to the play documentation, you just need to call Evolutions.cleanupEvolutions(database) after the test. See here https://www.playframework.com/documentation/2.4.x/ScalaTestingWithDatabases

Goss answered 11/6, 2015 at 9:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.