Rolling an evolution back

旧城冷巷雨未停 提交于 2019-12-03 22:24:41

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!