Search code examples
scalaplayframeworkslickplayframework-evolutions

How do you delete an evolution in Play?


In Play (scala) I have a number of evolutions in conf/evolutions/default called 1.sql, 2.sql etc...

Some of these are from playing around, and some are from tutorial code I no longer use.

How do I get rid of these evolutions?

The obvious approach of deleting the evolution files does not seem to work. If you remove the file, the evolution is still applied. Altering the file works, and so the current workaround is emptying the .sql files when they are longer required.


Solution

  • In virtually every migration framework/library/approach it works the same:

    • if you are using migrations/evolutions seriously (you deploy to production or at least you cooperate with other people, who wouldn't want their environment broken) - you simply don't remove migration. If you want to remove it, write a new migration that reverts the previous one.
    • if changes are only on your own branch, you haven't deployed it anywhere, you haven't shared your code - remove file, remove lines form file and drop and recreate database - migrations are backed up in execution in the database they are executed against (at least the majority of the tools I used do this), so if you want to get rid of migration it also need to be removed the the table that stores executed migrations. To ensure that things are consistent, the easiest way is to drop and rerun migrations/evolutions.

    I cannot stress this enough - if you deployed you code anywhere, do not remove the migration. Hell can break loose. But it you haven't deployed it anywhere, because it's e.g. just a tutorial, just drop the database and do whatever you want.