Integrating a Model in the Development Process

The following diagram shows you how to integrate a model in a Platform application.

Flyway Migration Process

* The migration script generation gradle command is: ./gradlew :gene-model:gene-model-jpa:generateJPAForce

You can see that depending on if you already have a model definition (jdl file) or not;

You will have to launch a gradle task to create a new version in migration scripts and ensure to make the script incremental. The script generated when you edit your model is placed in the following location: gene-model/gene-model-jpa/flyway/db/migration/ and is called: V1.0.000__CREATE_TABLES_AND_CONSTRAINTS.sql.

For example, if I have created an application V1 and now I want to update the JDL with some modification of my data model V2 (e.g. add the category table) without losing the existing data.

  1. I need to update the JDL file to implement my new model (V2).

  2. I create a flyway migration script "V2.0.0.xxxx.sql" under the folder gene-model/gene-model-jpa/flyway/db/migration/ that will contain the SQL code required to update the schema accordingly to the new model and migrate the existing data (V1).

  3. I can rebuild and restart the application with the new model.

Note:

Note that the V1xxxx SQL script is generated only if the migration is empty; To force the regeneration of the V1xxx SQL Script you can use ./gradlew :gene-model:gene-model-jpa:generateJPAForce. This can be useful to generate a new SQL and manually extract the diff with an existing schema.