ninja
ninja copied to clipboard
How to generate db script based on model
How to generate db script based on model Create table
You could either use something like JPA or ebean (https://github.com/ninjaframework/ninja-ebean) to that end.
Or maybe I got it wrong and you mean the DDL? Then you could use JPA/Hibernate which support that.
But to be honest - I always do this via flyway manually. It's much better and you'll need migrations anyway in reality.
(Sorry for necroposting.)
If you choose Ebean, then it could help you to create the whole database (CREATE ALL) with ebean-ddl-generator
.
Please note that since Ebean 12.7.1 (see ebean-orm/ebean#2162) it's not included in ebean
but in ebean-test
only.
Ebean could also help with migrations: not just generating them but also running them:
Ebean can generate the migrations for us by performing a diff on the model and then generating database platform specific DDL for the change.
Ebean can also run the migrations (similar to FlywayDb). It is recommended to use Ebean's built in migration runner rather than
FlywayDb
orLiquiBase
.