Community contributed extensions

Carbonate

Module for creating and running database migrations for Play application. To use the module add the module to your application.conf file

module.carbonate=${play.path}/modules/carbonate-{version}

Next configure the database and add the carbonate path in to the application.conf file, here we are using framework id local-mysql

%local-mysql.db=
%local-mysql.db.url=jdbc:mysql://localhost:3306/play-test
%local-mysql.db.driver=com.mysql.jdbc.Driver
%local-mysql.db.user=root
%local-mysql.db.pass=
%local-mysql.jpa.ddl=none
%local-mysql.carbonate.path=conf/migrations

Now you can create a new migration by

play carbonate:new --%local-mysql

The tool will ask for a short description for the migration which will be added to the migration file name, and then it will create the migration file to the path defined by the carbonate.path property. It will compare the models with the database and generate a schema update SQL based on that.

You should always check the migration generated by the tool before accepting it to production use!

The new migration will be applied to the database the next time you run your play application

play run --%local-mysql

Please note that if the application.conf is missing the carbonate.path property the migrations will just be ignored, which is useful if you want to use the mem database in play.

Configuration options

carbonate.path       - Path to the migrations folder. If missing the migrations will not be run.
carbonate.delimeter      - Delimeter string to use to separate the generated migration statements. Default value ';'.
carbonate.comment        - Comment string used in migrations. Default value '--'.