Child pages
  • Coding new DDL
Skip to end of metadata
Go to start of metadata

This document helps developers work with Grouper DDL.  If you work with Grouper DDL, please keep this document up to date.

The first thing to know about is the grouper_ddl table.  This has one entry for each ddl type.  A ddl type means database objects with a certain prefix (e.g. the grouper one starts with grouper_, the default subject one starts with subject, and the organization management one starts with grouperorgs_).  On startup, grouper will see if the version in the DB matches the version in the jar (an enum).  If not, an error will be logged, and optionally grouper will try to auto-upgrade in 2.5 or print out a script to run if not auto-ddl.

Each version of grouper that changes DDL should have its own class.  See for an example

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 typeCheckDescriptionExample
New tableCheck if going to current version of aboveThis is not that important since it is only called from current version
 GrouperDdl.V32.getVersion() <= ddlVersionBean.getBuildingToVersion();
New column,view, comment, index, foreign key, etcCheck if going to current version of aboveThis is important since the method is called from two places,
  1. when the table/object is created
  2. when this version is upgraded
GrouperDdl.V32.getVersion() <= ddlVersionBean.getBuildingToVersion();
Changed view

This is complicated and requires multiple steps (example in 2.5)

  1. In previous version, if building to that version, create some view with same name.
  2. In current version, if not building from scratch, drop the view
  3. 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

previous version:

GrouperDdl.V32.getVersion() > ddlVersionBean.getBuildingToVersion();

building from scratch:

ddlVersionBean.getBuildingFromVersion() <= 0
Update statementCheck to see if needs to updateYou can check by version number or see if you can find the table in the object model (isTableNew)
    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);

  • No labels