Create/update DB

Overview

This page documents the use of admin tools to create or update a DB schema.

This admin tool is used to create the schema (for a new installation) or update it (for a deployment of updated model objects).

Prerequisites

  • MySQL database must already exist (e.g. "umlsdb").
  • MySQL database connection parameters must be defined in the properties file specified by "run.config.umls".

Details

This tool is used to create an initial DB schema, or update the schema upon code changes to add or change existing fields.  

NOTE: fields that get removed are not handled by this process nor are declarations of new indexes nor statements in the "import.sql" file. Changes in these resources will require explicit creation in a database that already is instantiated with data.  Additionally, addition of a non-nullable field without a default to a table containing rows already can be problematic.  The typical strategy or adding a non nullable field is this:

  • Add a new field as nullable
  • Set the values appropriately (using an admin task).
  • In a future deployment, update the model to make this field not-nullable.

Creating a Database

Following are details on creating a database.

Mojo: UpdateDbMojo.java (in admin/mojo/src/main/resources/java/com/wci/umls/server/mojo)
Project: admin/db
Configuration Parameters

  • A profile of "Createdb" must be specified
  • run.config.umls - the standard configuration file specified as a -D parameter
  • This will destroy database contents, recreate the schema, and load the contents of the "import.sql" file.

Updating a Database

Following are details on updating a database.

Mojo: UpdateDbMojo.java (in admin/mojo/src/main/resources/java/com/wci/umls/server/mojo)
Project: admin/db
Configuration Parameters

  • A profile of "Updatedb" must be specified
  • run.config.umls - the standard configuration file specified as a -D parameter
  • This will update the schema and preserve any existing content.  It does not load the contents of the "import.sql" file.

Samples

Sample command line call of the admin tool to create a DB:

 

% cd ~/code/admin/db
% mvn install -PCreatedb -Drun.config.umls=/home/ec2-tomcat/config/config.properties

 

Sample command line call of the admin tool to simply update an existing DB:

 

% cd ~/code/admin/db
% mvn install -PUpdatedb -Drun.config.umls=/home/ec2-tomcat/config/config.properties

 

Sample Eclipse run configuration to create a DB:

Sample Eclipse run configuration to update a DB:

  • n/a