Ebean can generate and execute
CREATE ALL and
DROP ALL DDL
scripts which create all the tables. This is used for testing purposes.
When running a test or suite of tests the DB is created entirely from scratch
ebean: test: platform: h2 # h2, postgres, mysql, oracle, sqlserver ddlMode: dropCreate # none | dropCreate | migrations | create dbName: myapp
If we don't want to use ebean-test we can instead set both
ebean.ddl.run properties to true in
application-test.yml (which is in src/test/resources) and in this way the
CREATE ALL DDL is only generated and executed when running tests.
ebean: ddl: generate: true run: true
When DDL is generated
db-drop-all.sql are generated
and put into the maven
target or gradle
When tests are run Ebean automatically regenerates these ddl script files and executes them prior to running the tests. This effectively recreates the database prior to running tests.
We can additionally specify DDL to execute prior to running the "create-all" DDL via the
We can additionally specify DDL to execute after running the "create-all" DDL which we typically
use to seed the database via the
Compared to DB Migrations
DB Migration is different in that
DIFF DDL scripts are generated for the
changes to the model and these
DIFF DDL scripts can be applied to the target database typically when