From a791a75b0a893308f35865542149c77f8761b3a0 Mon Sep 17 00:00:00 2001
From: Philip Häusler <msquare@notrademark.de>
Date: Wed, 17 Dec 2014 17:22:35 +0100
Subject: integrate shift type into shifts

---
 db/update.sql | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'db/update.sql')

diff --git a/db/update.sql b/db/update.sql
index 7375b507..401be215 100644
--- a/db/update.sql
+++ b/db/update.sql
@@ -11,6 +11,13 @@ ALTER TABLE `ShiftTypes` ADD FOREIGN KEY ( `angeltype_id` ) REFERENCES `engelsys
 INSERT INTO `engelsystem`.`Privileges` (`id`, `name`, `desc`) VALUES (NULL , 'shifttypes', 'Administrate shift types');
 INSERT INTO `GroupPrivileges` SET `group_id`=-5, `privilege_id`=(SELECT `id` FROM `Privileges` WHERE `name`='shifttypes');
 
+ALTER TABLE `Shifts` ADD `shifttype_id` INT NOT NULL AFTER `SID`, ADD INDEX ( `shifttype_id` );
+INSERT INTO `ShiftTypes` SELECT DISTINCT NULL , `name` , NULL , '' FROM `Shifts`;
+UPDATE `Shifts` SET `shifttype_id`=(SELECT `id` FROM `ShiftTypes` WHERE `ShiftTypes`.`name`=`Shifts`.`name`);
+ALTER TABLE `Shifts` DROP `name`;
+ALTER TABLE `Shifts` ADD FOREIGN KEY ( `shifttype_id` ) REFERENCES `engelsystem`.`ShiftTypes` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+ALTER TABLE `Shifts` ADD `title` TEXT NULL AFTER `SID`;
+
 /* cleanup */
 ALTER TABLE `User` DROP `ICQ` ;
 
-- 
cgit v1.2.3-54-g00ecf

