...
Each object that is changed should be in its own method. Check to make sure if it has been done before. See if it should even run. There are a few cases
Object type | Check | Description | Example |
---|
New table | Check if going to current version of above | This is not that important since it is only called from current version |
Code Block |
---|
GrouperDdl.V32.getVersion() <= ddlVersionBean.getBuildingToVersion(); |
|
New column,view, comment, index, foreign key, etc | Check if going to current version of above | This is important since the method is called from two places,
- when the table/object is created
- when this version is upgraded
|
Code Block |
---|
GrouperDdl.V32.getVersion() <= ddlVersionBean.getBuildingToVersion(); |
|
Changed view | This is complicated and requires multiple steps (example in 2.5) - In previous version, if building to that version, create some view with same name.
- In current version, if not building from scratch, drop the view
- in current version, if building to current version of above, create the view
| If you dont create the view with temp name in previous version, then ddlutils wont detect that it needs to drop it | |
V31<=> ddlVersionBean.getBuildingToVersion(); |
building from scratch: Code Block |
---|
ddlVersionBean.getBuildingFromVersion() <= 0 |
|
Update statement | Check to see if needs to update | You can check by version number or see if you can find the table in the object model (isTableNew) |
Code Block |
---|
Table groupTable = GrouperDdlUtils.ddlutilsFindTable(database, Group.TABLE_GROUPER_GROUPS, true);
boolean enabledColumnIsNew = false;
if (groupTable != null) {
enabledColumnIsNew = null == GrouperDdlUtils.ddlutilsFindColumn(groupTable, Group.COLUMN_ENABLED, false);
}
|
|