Skip to main content

Generating SQL Scripts

Generating scripts​

Generating SQL scripts with the SQL ExpandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. is as simple as adding the expansion resourceExpansion Resource (ExpansionResource). A reusable resource bundle containing expanders and features that provide specific application capabilities, defined in the expansion settings and added to the classpath during expansion.. It will automatically generate a script to generate a file to provision an SQL schema structure with the correct database dialect based on the settings of your ApplicationInstance model.

Aside from purely generating the SQL scheme to store your data, it will also attempt to provision the needed infrastructure for your persistence framework depending on which you have selected in your ApplicationInstance model. At this time, infrastructure for several methods of id generation in both Hibernate and OpenJPA are supported.

Scripts to provision the database schema(s) will be generated as [APPLICATION_ROOT]/database/001-app-database.sql.

Option
sql.structureFile.name ApplicationApplicationInstance

This option can be used to defined the name of the initial database structure script that is generated by the expandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact.. The name should not include the extension, as this is added by the expandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. themselves.

<options>
<sql.structureFile.name>000-init-database</sql.structureFile.name>
</options>
<options>
<sql.structureFile.name>V1__initial_table_structure</sql.structureFile.name>
</options>
Option
excludeFromSqlGeneration Component

Entire components can easily be excluded from SQL script generation by adding this option. All components that do not have this option set, will be included in the SQL scripts.

<options>
<excludeFromSqlGeneration/>
</options>

Initial data provisioning​

It is possible to generate a script with initial data for a clean deployment. The SQL ExpandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. provide an XML representation for the data represented by DataElements that is database-technology agnostic.

More in-depth information can be found on the dedicated page.