2 - Extending the schema
2 - Extending the schema
After extending the Commerce Engine's domain and service layers to support automatic subscription renewal, you'll need to extend the database schema so the Order's autoBill value can be stored.
This section of the tutorial will show you how to extend the database schema using Liquibase changesets.
Extending the TORDER table
The database stores Orders in the TORDER table. To extend the TORDER table, you'll create a new table named TORDEREXT that contains an AUTOBILL column. You'll also add a discriminator column to TORDER that maps the extended order data in TORDEREXT with the out of the box order data in TORDER.
To extend the TORDER table:
- In extensions/database directory,
open extensions/database/ext-data/src/main/resources/schema/schema-customizations-changelog.xml,
and add the following XML before the </databaseChangeLog> tag.
<changeSet id="BN-595.1" author="elasticpath"> <createTable tableName="TORDEREXT"> <column name="UIDPK" type="BIGINT"> <constraints primaryKey="true" nullable="false"/commerce-legacy/> </column> <column name="AUTOBILL" type="INTEGER" defaultValue="0"> </column> </createTable> </changeSet> <changeSet id="BN-595.2" author="elasticpath"> <addColumn tableName="TORDER"> <column name="ORDERTYPE" type="VARCHAR(20)"/commerce-legacy/> </addColumn> </changeSet>
- With the command prompt, navigate to extensions/database and run
the command:
mvn clean install -Preset-db
This will apply the changesets you added to schema-customizations-changelog.xml to your database.