Page tree

Overview

This page documents the use of admin tools to create a database or update an existing database to the latest schema based on the current state of the model objects..

Prerequisites

  • MySQL database must already exist (e.g. "refset")  
  • MySQL database connection parameters must be defined in the properties file specified by "refset.config".
  • IMPORTANT: The Tomcat server must not be running while this is invoked.
  • IMPORTANT: If you are trying to destroy and recreate the database
    • First run the contents of admin/src/main/resources/truncate_all.sql into your database
    • Also, make sure to clear your index files (or immediately run the Reindex Objects tool).
  • IMPORTANT: To update an existing database (to add fields, etc), make sure to run with -PUpdatedb instead of -PCreatedb

Details

This tool is used to either create a database for the tool, or update an existing schema based on changes in the code (while retaining data and indexes already loaded)

Following are some details about the implementation of this tool:

Mojo: UpdateDbMojo.java (in admin/src/main/resources/java/org/ihtsdo/otf/refset/mojo)
Project: admin
Configuration Parameters

  • Profile 
    • "Createdb"  - for creating a database
    • "Updatedb" - for updating an existing schema
  • refset.config - the standard configuration file specified as a -D parameter

Samples

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

% cd /home/ihtsdo/refset/code/admin
% mvn install -PCreatedb -Drefset.config=/home/ihtsdo/refset/config/config.properties

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

% cd /home/ihtsdo/refset/code/admin
% mvn install -PUpdatedb -Drefset.config=/home/ihtsdo/refset/config/config.properties

Troubleshooting

The main issue with "Createdb" has to do with a legacy table structure with indexes or foreign keys that are no longer valid.  Clear the state of the database first by either dropping and recreating the schema, or by running the contents of "admin/src/main/resources/truncate_all.sql" into your database.

# stop the server
% service tomcat7 stop

% cd /home/ihtsdo/refset/code
% mysql -u<user> -p refset < admin/src/main/resources/truncate_all.sql
 
...
  • n/a

 

  • No labels