Manually adding additional attributes

Goal: Add some additional attributes to the UM’s data model.

  1. A new (secondary) STRING attribute favorite_color

  2. A new (primary) TEXT attribute cv

  3. A new TABLE attribute pets with three columns (name: STRING, legs: INTEGER)

You can download the whole Kickstarter-based sample application from our GitLab repository: um-public/tutorial-additional-attributes

Start a new Kickstarter project

umkickstarter cd umkickstarter # Copy your partner license file to env/devel/cmsbs-conf/cmsbs.license gradle setup run

 

Create a new attributes config file

Create a new file: cmsbs-conf/conf.d/tutorial.attributes:

# Pinuts File Encoding: UTF-8 additional.attributes[] = favorite_color grp.std_personal.members[] = favorite_color favorite_color.type = STRING favorite_color.title = Favorite Color favorite_color.values = red blue yellow green black white brown gray favorite_color.values[] = ""

Login to http://localhost:8080/cmsbs as admin / admin and create a handful of new customer Entries.

Add a primary attribute

Edit the file cmsbs-conf/conf.d/tutorial.attributes again and add:

additional.attributes[] = cv grp.std_personal.members[] = cv cv.type = TEXT cv.isPrimary = true cv.title = Curriculum vitae

Restart your UM and try to create another customer Entry.

Adding a new Entry or even listing existing Entries fails:

Column "P_CV" not found; SQL statement

The DB column p_cv that is required for primary attributes is missing and will not be created automatically.

Update DB schema manually

In this tutorial we want to update our DB schema manually. However, this can of course be automated as described in https://pinutswiki.atlassian.net/wiki/spaces/UMDOC/pages/1463713875.

Stop your UM and open the H2 console:

This should start a local minimalistic web-based SQL console. Your favorite browser should automatically pop up. Now, take a look around the list of DB tables to the left and finally create the missing column:

Under Windows / WSL you’ll need to replace http://127.0.1.1 by http://localhost in the address bar when your browser pops up.

If the H2 console still won’t work, you most likely want to cheat here and just wipe the DB and start over:

gradle destroy

(When UM starts up with a completely empty DB, all required columns will be created automatically.)

Restart your UM and once again try to create a new Entry:

Add a table attribute

Edit the file cmsbs-conf/conf.d/tutorial.attributes again and add:

Restart your UM and try to create another customer Entry.

The DB table (a_pets) needed to store the new pets table attribute will be created automatically. However, successive changes will require manual schema updates.