Description of problem: From time to time we need to change the database schema used by Cumin. To date, we have given users instructions in release notes on how to drop and recreate the cumin database. This causes the loss of data and adds extra install tasks for the users. We should have a general mechanism that allows users to upgrade the schema through a cumin-admin command when necessary. Many schema changes can be handled easily via scripts without any data loss with this kind of mechanism
Fixed in revision 5020. Added the 'cumin-admin upgrade-schema' command. This command will look in $CUMIN_HOME/model/upgrades (typically /usr/share/cumin/model/upgrades) for scripts that can be run to upgrade an existing cumin database to the schema version expected by the current cumin install. Scripts are named following the convention v1_to_v2 where v1 is the current version and v2 is the target version and v1 and v2 will typically be of the form Major.Minor The command will look for a chain of files that can be executed to upgrade the schema to the target version, and will prompt the user for confirmation. The schema version number in the database will be updated after each script completes successfully. There is no rollback. If a user cannot upgrade successfully, then a drop and create of the database with loss of sample data is the fallback (user database can usually be saved with export/import users). Additionally, the cumin service start script will check for the expected schema version and fail to start with a message if the version is not as expected. A few ideas for testing upgrade-schema The schema version can artificially be changed like the following $ echo UPDATE \"com.redhat.cumin\".\"Info\" SET schema_version = \'0.8\' | psql -d cumin -U cumin -h localhost Executable scripts with success or failure exit status can be created manually in $CUMIN_HOME/model/upgrades, such as 0.1_to_0.2 0.2_to_0.3 and so on
Tweaked in revision 5022, exception handler format corrected for Python 2.4
Technical note added. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. New Contents: Cause Cumin provided no facility to modify the schema of an existing database on a software upgrade. Consequence If an upgrade included schema changes, users were required to drop and recreate the database to incorporate the new schema version. This resulted in loss of data. Change A new 'cumin-admin upgrade-schema' command has been added that allows users to apply schema changes as part of a software upgrade. This command will run necessary scripts to upgrade the schema to the newest version without loss of data. If there are no schema changes to apply the user will be informed and no action will be taken. Result Users may now safely run the 'cumin-admin upgrade-schema' command as a routine step in a software upgrade.
# rpm -q cumin cumin-0.1.4916-1.el6.noarch # service cumin stop # yum update # rpm -q cumin cumin-0.1.5047-1.el6.noarch # cumin-admin upgrade-schema Attempting to upgrade the schema from 1.0 to 1.1 Found an update path. Alter the schema? [yes]|no: Executing script /usr/share/cumin/model/upgrades/1.0_to_1.1 Upgrade to schema version 1.1 succeeded
*** Bug 680266 has been marked as a duplicate of this bug. ***
Technical note updated. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. Diffed Contents: @@ -1,11 +1 @@ -Cause +Previously, the Cumin web console provided no facility to modify the schema of an existing database on a software upgrade. Consequently, if an upgrade included schema changes, users were required to drop and recreate the database to incorporate the new schema version. This resulted in loss of data. With this update, a new "cumin-admin upgrade-schema" command has been added that allows users to apply schema changes as part of a software upgrade. This command runs necessary scripts to upgrade the schema to the newest version without any loss of data. If there are no schema changes to apply, the user is be informed and no action is taken.- Cumin provided no facility to modify the schema of an existing database on a software upgrade. - -Consequence - If an upgrade included schema changes, users were required to drop and recreate the database to incorporate the new schema version. This resulted in loss of data. - -Change - A new 'cumin-admin upgrade-schema' command has been added that allows users to apply schema changes as part of a software upgrade. This command will run necessary scripts to upgrade the schema to the newest version without loss of data. If there are no schema changes to apply the user will be informed and no action will be taken. - -Result - Users may now safely run the 'cumin-admin upgrade-schema' command as a routine step in a software upgrade.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHEA-2012-0045.html