Panel | ||
---|---|---|
| ||
This section describes how custom database changes can be made, defining those changes in XML files rather that writing SQL directly against the database.
What does this section cover?
|
...
DATABASECHANGELOG table is used to keep track of those changes.
...
Database Object Changelog
New tables, columns and constraints are defined in in <projectname>.changelog.xml under xml which is located under ProjectNameCrmEJB/ejbModule.
Create New Table
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<databaseChangeLog> ... <changeSet author="custom_developer" id="custom-db-change-1"> <createTable tableName="CUSTOMTABLE"> <column name="CUSTOMID" remarks="Primary Key" type="VARCHAR(32)"> <constraints nullable="false"/> </column> <column name="CUSTOMNAME" remarks="The name of the custom entity" type="VARCHAR(256)"/> <column name="CUSTOMALTCODE" type="VARCHAR(32)"/> <column name="CUSTOMDESC" remarks="The description of the custom entity" type="VARCHAR(512)"/> <column name="CUSTOMCREATEDDATE" type="TIMESTAMP"/> <column name="CUSTOMUPDATEDDATE" type="TIMESTAMP"/> <column name="CUSTOMDELETED" type="INTEGER"/> <column name="CUSTOMCREATEDBYUSERID" type="VARCHAR(32)"/> <column name="CUSTOMUPDATEDBYUSERID" type="VARCHAR(32)"/> <column name="CUSTOMCREATEDBYOUUID" type="VARCHAR(32)"/> <column name="CUSTOMUPDATEDBYOUUID" type="VARCHAR(32)"/> <column defaultValueNumeric="0" name="RECVERSION" type="INTEGER"> <constraints nullable="false"/> </column> </createTable> </changeSet> ... </databaseChangeLog> |
Add New Column To An Existing Table
New columns can be added to both release and custom tables.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<databaseChangeLog>
...
<changeSet author="custom_developer" id="custom-db-change-2">
<addColumn tableName="CUSTOMTABLE">
<column name="RENTALID" remarks="The rental related with the custom entity - FK to TRN_RENTALS" type="VARCHAR(32)"/>
</addColumn>
</changeSet>
...
</databaseChangeLog> |
Add a Foreign Key Constraint
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<databaseChangeLog>
...
<changeSet author="p_kestora" id="CRMCOM-5483-05">
<addForeignKeyConstraint baseColumnNames="RENTALID" baseTableName="CUSTOMTABLE" constraintName="FK_CUSTOMTABLE_01" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="RENTALID" referencedTableName="TRN_RENTALS"/>
</changeSet>
...
</databaseChangeLog> |