CDash:Database
In this section we discuss the coding design related to the database. Currently CDash supports MySQL and PostGreSQL so make sure the code you write, especially the SQL queries are working for both instances.
Adding/Changing database fields
When adding, removing or changing fields to an existing table, follow the following instructions
- Edit the SQL files to reflect your changes
- cdash/sql/mysql/cdash.sql (for new installations)
- cdash/sql/pgsql/cdash.sql (for new installations)
- Edit backwardCompatibilityTools.php
- Search for the upgrade section upgrade-A-B where A.B represents the major.minor version of the upcoming stable release
- Use the AddTableField(), AddTableIndex(), ModifyTableField(), etc... functions. These functions make sure that if the query is called twice it doesn't modify the schema again.
- PGSQL doesn't like the "ON UPDATE" function in the schema, so avoid it and do the update manually in your queries.
Creating a completely new table
To add a completely new table you just need to edit:
- cdash/sql/mysql/cdash.sql (for new installations)
- cdash/sql/pgsql/cdash.sql (for new installations)
- cdash/sql/mysql/cdash-upgrade-A.B-C.D (for current installation)
- cdash/sql/pgsql/cdash-upgrade-A.B-C.D (for current installation)
Where A.B is the major.minor version of the current stable release and C.D is the major.minor version of the upcoming stable release.
Automatic translation to PGSQL
The postgres layer in cdash relies on some of the features of the mysqlcompat package: http://pgfoundry.org/projects/mysqlcompat
The following patch to the mysqlcompat package is required to use it with recent versions of PostgreSQL: http://public.kitware.com/Wiki/images/d/d0/Mysqlcompat.txt
(Note that this *is* actually a patch file, but the CDash wiki doesn't allow upload of files ending with ".patch".)
Installation on Ubuntu
apt-get install libsql-translator-perl
Then run the script
CDash/sql/convert.sh
Warning The indexes generated by the script are all the same so you would need to prepend the table name.