We are using play 1.2.x DB evolutions feature. I want to have the scripts to create and develop schema being tested in play auto-test
So I need an empty DB before tests suite.
I thought about:
- registering @OnApplicationStartup listener that could delete all
structures in DB (which would require some dirty code probably), and
let db evolutions do the rest. But play evolutions are as well an
@OnApplicationStartup and I don’t know how to make sure my listener
will be the first. This could be overcome with another hack – calling
DB evolutions from code. - dropping and recreating DB with some script – before running
auto-test, but that doesn’t make my test be always the test I want. e.g. I need to always remember to use my script not only auto-test. This script will not be executed when executing test from eclipse.
Are there any other options?
Or maybe someone can suggest any other solution for testing this stuff?
Thanks
Simpler: use an in-memory database (compatible in syntax with your prod database so that the SQL works fine).
You’ll have a new db each run, and evolutions will execute always.