pmsipilot/Jenkins-Khan — pull request #32 by srogier (2012-03-21 17:06:58+00:00)
Title: fix errors in database's schema

* use sf_guard_user_id instead of username (historical (!) usage before use of sfGuardPlugin)
* remove git_branch of jenkins_run : this property if part of a jenkins_group_run

How to update

```SQL

ALTER TABLE `jenkins_group_run` ADD `sf_guard_user_id` INT NOT NULL AFTER `id` ,
ADD INDEX ( `sf_guard_user_id` );

UPDATE
jenkins_group_run JOIN
sf_guard_user ON (sf_guard_user.username = jenkins_group_run.user_id)
SET jenkins_group_run.sf_guard_user_id = sf_guard_user.id;

DELETE FROM
jenkins_run
USING
jenkins_run
JOIN jenkins_group_run ON (jenkins_run.jenkins_group_run_id = jenkins_group_run.id)
WHERE
jenkins_group_run.sf_guard_user_id=0;

DELETE FROM
jenkins_group_run
WHERE
jenkins_group_run.sf_guard_user_id=0;

ALTER TABLE `jenkins_group_run` ADD FOREIGN KEY ( `sf_guard_user_id` ) REFERENCES `jenkins_khan`.`sf_guard_user` (
`id`
) ON DELETE RESTRICT ON UPDATE RESTRICT ;

ALTER TABLE `jenkins_khan`.`jenkins_group_run` DROP INDEX `natural_pk` ,
ADD UNIQUE `natural_pk` ( `sf_guard_user_id` , `git_branch` ) ;

ALTER TABLE `jenkins_group_run` DROP `user_id` ;

ALTER TABLE jenkins_run DROP git_branch;
```